Skip to content

Commit cb792ef

Browse files
committed
Revert EIP-2464
1 parent e46f41d commit cb792ef

File tree

210 files changed

+3858
-9969
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+3858
-9969
lines changed

cmd/bootnode/main.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"github.com/XinFinOrg/XDPoSChain/log"
3030
"github.com/XinFinOrg/XDPoSChain/p2p/discover"
3131
"github.com/XinFinOrg/XDPoSChain/p2p/discv5"
32-
"github.com/XinFinOrg/XDPoSChain/p2p/enode"
3332
"github.com/XinFinOrg/XDPoSChain/p2p/nat"
3433
"github.com/XinFinOrg/XDPoSChain/p2p/netutil"
3534
)
@@ -86,7 +85,7 @@ func main() {
8685
}
8786

8887
if *writeAddr {
89-
fmt.Printf("%v\n", enode.PubkeyToIDV4(&nodeKey.PublicKey))
88+
fmt.Printf("%v\n", discover.PubkeyID(&nodeKey.PublicKey))
9089
os.Exit(0)
9190
}
9291

@@ -119,17 +118,16 @@ func main() {
119118
}
120119

121120
if *runv5 {
122-
if _, err := discv5.ListenUDP(nodeKey, conn, "", restrictList); err != nil {
121+
if _, err := discv5.ListenUDP(nodeKey, conn, realaddr, "", restrictList); err != nil {
123122
utils.Fatalf("%v", err)
124123
}
125124
} else {
126-
db, _ := enode.OpenDB("")
127-
ln := enode.NewLocalNode(db, nodeKey)
128125
cfg := discover.Config{
129-
PrivateKey: nodeKey,
130-
NetRestrict: restrictList,
126+
PrivateKey: nodeKey,
127+
AnnounceAddr: realaddr,
128+
NetRestrict: restrictList,
131129
}
132-
if _, err := discover.ListenUDP(conn, ln, cfg); err != nil {
130+
if _, err := discover.ListenUDP(conn, cfg); err != nil {
133131
utils.Fatalf("%v", err)
134132
}
135133
}

cmd/faucet/faucet.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ import (
5454
"github.com/XinFinOrg/XDPoSChain/log"
5555
"github.com/XinFinOrg/XDPoSChain/node"
5656
"github.com/XinFinOrg/XDPoSChain/p2p"
57+
"github.com/XinFinOrg/XDPoSChain/p2p/discover"
5758
"github.com/XinFinOrg/XDPoSChain/p2p/discv5"
58-
"github.com/XinFinOrg/XDPoSChain/p2p/enode"
5959
"github.com/XinFinOrg/XDPoSChain/p2p/nat"
6060
"github.com/XinFinOrg/XDPoSChain/params"
6161
"github.com/gorilla/websocket"
@@ -262,10 +262,8 @@ func newFaucet(genesis *core.Genesis, port int, enodes []*discv5.Node, network u
262262
return nil, err
263263
}
264264
for _, boot := range enodes {
265-
old, err := enode.ParseV4(boot.String())
266-
if err != nil {
267-
stack.Server().AddPeer(old)
268-
}
265+
old, _ := discover.ParseNode(boot.String())
266+
stack.Server().AddPeer(old)
269267
}
270268
// Attach to the client and retrieve and interesting metadatas
271269
api, err := stack.Attach()

cmd/p2psim/main.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,21 @@
1919
// Here is an example of creating a 2 node network with the first node
2020
// connected to the second:
2121
//
22-
// $ p2psim node create
23-
// Created node01
22+
// $ p2psim node create
23+
// Created node01
2424
//
25-
// $ p2psim node start node01
26-
// Started node01
25+
// $ p2psim node start node01
26+
// Started node01
2727
//
28-
// $ p2psim node create
29-
// Created node02
28+
// $ p2psim node create
29+
// Created node02
3030
//
31-
// $ p2psim node start node02
32-
// Started node02
31+
// $ p2psim node start node02
32+
// Started node02
33+
//
34+
// $ p2psim node connect node01 node02
35+
// Connected node01 to node02
3336
//
34-
// $ p2psim node connect node01 node02
35-
// Connected node01 to node02
3637
package main
3738

3839
import (
@@ -46,7 +47,7 @@ import (
4647

4748
"github.com/XinFinOrg/XDPoSChain/crypto"
4849
"github.com/XinFinOrg/XDPoSChain/p2p"
49-
"github.com/XinFinOrg/XDPoSChain/p2p/enode"
50+
"github.com/XinFinOrg/XDPoSChain/p2p/discover"
5051
"github.com/XinFinOrg/XDPoSChain/p2p/simulations"
5152
"github.com/XinFinOrg/XDPoSChain/p2p/simulations/adapters"
5253
"github.com/XinFinOrg/XDPoSChain/rpc"
@@ -282,7 +283,7 @@ func createNode(ctx *cli.Context) error {
282283
if err != nil {
283284
return err
284285
}
285-
config.ID = enode.PubkeyToIDV4(&privKey.PublicKey)
286+
config.ID = discover.PubkeyID(&privKey.PublicKey)
286287
config.PrivateKey = privKey
287288
}
288289
if services := ctx.String("services"); services != "" {

cmd/utils/flags.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ import (
5151
"github.com/XinFinOrg/XDPoSChain/metrics/exp"
5252
"github.com/XinFinOrg/XDPoSChain/node"
5353
"github.com/XinFinOrg/XDPoSChain/p2p"
54+
"github.com/XinFinOrg/XDPoSChain/p2p/discover"
5455
"github.com/XinFinOrg/XDPoSChain/p2p/discv5"
55-
"github.com/XinFinOrg/XDPoSChain/p2p/enode"
5656
"github.com/XinFinOrg/XDPoSChain/p2p/nat"
5757
"github.com/XinFinOrg/XDPoSChain/p2p/netutil"
5858
"github.com/XinFinOrg/XDPoSChain/params"
@@ -696,10 +696,9 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
696696
case ctx.GlobalBool(XDCTestnetFlag.Name):
697697
urls = params.TestnetBootnodes
698698
}
699-
700-
cfg.BootstrapNodes = make([]*enode.Node, 0, len(urls))
699+
cfg.BootstrapNodes = make([]*discover.Node, 0, len(urls))
701700
for _, url := range urls {
702-
node, err := enode.ParseV4(url)
701+
node, err := discover.ParseNode(url)
703702
if err != nil {
704703
log.Error("Bootstrap URL invalid", "enode", url, "err", err)
705704
continue

cmd/wnode/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import (
4040
"github.com/XinFinOrg/XDPoSChain/crypto"
4141
"github.com/XinFinOrg/XDPoSChain/log"
4242
"github.com/XinFinOrg/XDPoSChain/p2p"
43-
"github.com/XinFinOrg/XDPoSChain/p2p/enode"
43+
"github.com/XinFinOrg/XDPoSChain/p2p/discover"
4444
"github.com/XinFinOrg/XDPoSChain/p2p/nat"
4545
"github.com/XinFinOrg/XDPoSChain/whisper/mailserver"
4646
whisper "github.com/XinFinOrg/XDPoSChain/whisper/whisperv6"
@@ -174,7 +174,7 @@ func initialize() {
174174
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*argVerbosity), log.StreamHandler(os.Stderr, log.TerminalFormat(false))))
175175

176176
done = make(chan struct{})
177-
var peers []*enode.Node
177+
var peers []*discover.Node
178178
var err error
179179

180180
if *generateKey {
@@ -202,7 +202,7 @@ func initialize() {
202202
if len(*argEnode) == 0 {
203203
argEnode = scanLineA("Please enter the peer's enode: ")
204204
}
205-
peer := enode.MustParseV4(*argEnode)
205+
peer := discover.MustParseNode(*argEnode)
206206
peers = append(peers, peer)
207207
}
208208

@@ -748,11 +748,11 @@ func requestExpiredMessagesLoop() {
748748
}
749749

750750
func extractIDFromEnode(s string) []byte {
751-
n, err := enode.ParseV4(s)
751+
n, err := discover.ParseNode(s)
752752
if err != nil {
753753
utils.Fatalf("Failed to parse enode: %s", err)
754754
}
755-
return n.ID().Bytes()
755+
return n.ID[:]
756756
}
757757

758758
// obfuscateBloom adds 16 random bits to the the bloom

0 commit comments

Comments
 (0)