Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert EIP 2464 #619

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions cmd/bootnode/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/XinFinOrg/XDPoSChain/log"
"github.com/XinFinOrg/XDPoSChain/p2p/discover"
"github.com/XinFinOrg/XDPoSChain/p2p/discv5"
"github.com/XinFinOrg/XDPoSChain/p2p/enode"
"github.com/XinFinOrg/XDPoSChain/p2p/nat"
"github.com/XinFinOrg/XDPoSChain/p2p/netutil"
)
Expand Down Expand Up @@ -86,7 +85,7 @@ func main() {
}

if *writeAddr {
fmt.Printf("%v\n", enode.PubkeyToIDV4(&nodeKey.PublicKey))
fmt.Printf("%v\n", discover.PubkeyID(&nodeKey.PublicKey))
os.Exit(0)
}

Expand Down Expand Up @@ -119,17 +118,16 @@ func main() {
}

if *runv5 {
if _, err := discv5.ListenUDP(nodeKey, conn, "", restrictList); err != nil {
if _, err := discv5.ListenUDP(nodeKey, conn, realaddr, "", restrictList); err != nil {
utils.Fatalf("%v", err)
}
} else {
db, _ := enode.OpenDB("")
ln := enode.NewLocalNode(db, nodeKey)
cfg := discover.Config{
PrivateKey: nodeKey,
NetRestrict: restrictList,
PrivateKey: nodeKey,
AnnounceAddr: realaddr,
NetRestrict: restrictList,
}
if _, err := discover.ListenUDP(conn, ln, cfg); err != nil {
if _, err := discover.ListenUDP(conn, cfg); err != nil {
utils.Fatalf("%v", err)
}
}
Expand Down
8 changes: 3 additions & 5 deletions cmd/faucet/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ import (
"github.com/XinFinOrg/XDPoSChain/log"
"github.com/XinFinOrg/XDPoSChain/node"
"github.com/XinFinOrg/XDPoSChain/p2p"
"github.com/XinFinOrg/XDPoSChain/p2p/discover"
"github.com/XinFinOrg/XDPoSChain/p2p/discv5"
"github.com/XinFinOrg/XDPoSChain/p2p/enode"
"github.com/XinFinOrg/XDPoSChain/p2p/nat"
"github.com/XinFinOrg/XDPoSChain/params"
"github.com/gorilla/websocket"
Expand Down Expand Up @@ -262,10 +262,8 @@ func newFaucet(genesis *core.Genesis, port int, enodes []*discv5.Node, network u
return nil, err
}
for _, boot := range enodes {
old, err := enode.ParseV4(boot.String())
if err != nil {
stack.Server().AddPeer(old)
}
old, _ := discover.ParseNode(boot.String())
stack.Server().AddPeer(old)
}
// Attach to the client and retrieve and interesting metadatas
api, err := stack.Attach()
Expand Down
25 changes: 13 additions & 12 deletions cmd/p2psim/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@
// Here is an example of creating a 2 node network with the first node
// connected to the second:
//
// $ p2psim node create
// Created node01
// $ p2psim node create
// Created node01
//
// $ p2psim node start node01
// Started node01
// $ p2psim node start node01
// Started node01
//
// $ p2psim node create
// Created node02
// $ p2psim node create
// Created node02
//
// $ p2psim node start node02
// Started node02
// $ p2psim node start node02
// Started node02
//
// $ p2psim node connect node01 node02
// Connected node01 to node02
//
// $ p2psim node connect node01 node02
// Connected node01 to node02
package main

import (
Expand All @@ -46,7 +47,7 @@ import (

"github.com/XinFinOrg/XDPoSChain/crypto"
"github.com/XinFinOrg/XDPoSChain/p2p"
"github.com/XinFinOrg/XDPoSChain/p2p/enode"
"github.com/XinFinOrg/XDPoSChain/p2p/discover"
"github.com/XinFinOrg/XDPoSChain/p2p/simulations"
"github.com/XinFinOrg/XDPoSChain/p2p/simulations/adapters"
"github.com/XinFinOrg/XDPoSChain/rpc"
Expand Down Expand Up @@ -282,7 +283,7 @@ func createNode(ctx *cli.Context) error {
if err != nil {
return err
}
config.ID = enode.PubkeyToIDV4(&privKey.PublicKey)
config.ID = discover.PubkeyID(&privKey.PublicKey)
config.PrivateKey = privKey
}
if services := ctx.String("services"); services != "" {
Expand Down
7 changes: 3 additions & 4 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import (
"github.com/XinFinOrg/XDPoSChain/metrics/exp"
"github.com/XinFinOrg/XDPoSChain/node"
"github.com/XinFinOrg/XDPoSChain/p2p"
"github.com/XinFinOrg/XDPoSChain/p2p/discover"
"github.com/XinFinOrg/XDPoSChain/p2p/discv5"
"github.com/XinFinOrg/XDPoSChain/p2p/enode"
"github.com/XinFinOrg/XDPoSChain/p2p/nat"
"github.com/XinFinOrg/XDPoSChain/p2p/netutil"
"github.com/XinFinOrg/XDPoSChain/params"
Expand Down Expand Up @@ -696,10 +696,9 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
case ctx.GlobalBool(XDCTestnetFlag.Name):
urls = params.TestnetBootnodes
}

cfg.BootstrapNodes = make([]*enode.Node, 0, len(urls))
cfg.BootstrapNodes = make([]*discover.Node, 0, len(urls))
for _, url := range urls {
node, err := enode.ParseV4(url)
node, err := discover.ParseNode(url)
if err != nil {
log.Error("Bootstrap URL invalid", "enode", url, "err", err)
continue
Expand Down
10 changes: 5 additions & 5 deletions cmd/wnode/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (
"github.com/XinFinOrg/XDPoSChain/crypto"
"github.com/XinFinOrg/XDPoSChain/log"
"github.com/XinFinOrg/XDPoSChain/p2p"
"github.com/XinFinOrg/XDPoSChain/p2p/enode"
"github.com/XinFinOrg/XDPoSChain/p2p/discover"
"github.com/XinFinOrg/XDPoSChain/p2p/nat"
"github.com/XinFinOrg/XDPoSChain/whisper/mailserver"
whisper "github.com/XinFinOrg/XDPoSChain/whisper/whisperv6"
Expand Down Expand Up @@ -174,7 +174,7 @@ func initialize() {
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*argVerbosity), log.StreamHandler(os.Stderr, log.TerminalFormat(false))))

done = make(chan struct{})
var peers []*enode.Node
var peers []*discover.Node
var err error

if *generateKey {
Expand Down Expand Up @@ -202,7 +202,7 @@ func initialize() {
if len(*argEnode) == 0 {
argEnode = scanLineA("Please enter the peer's enode: ")
}
peer := enode.MustParseV4(*argEnode)
peer := discover.MustParseNode(*argEnode)
peers = append(peers, peer)
}

Expand Down Expand Up @@ -748,11 +748,11 @@ func requestExpiredMessagesLoop() {
}

func extractIDFromEnode(s string) []byte {
n, err := enode.ParseV4(s)
n, err := discover.ParseNode(s)
if err != nil {
utils.Fatalf("Failed to parse enode: %s", err)
}
return n.ID().Bytes()
return n.ID[:]
}

// obfuscateBloom adds 16 random bits to the the bloom
Expand Down
Loading