les: switch to new discv5 (#21940)
This PR enables running the new discv5 protocol in both LES client and server mode. In client mode it mixes discv5 and dnsdisc iterators (if both are enabled) and filters incoming ENRs for "les" tag and fork ID. The old p2p/discv5 package and all references to it are removed. Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
@ -22,12 +22,12 @@ package geth
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/ethereum/go-ethereum/p2p/discv5"
|
||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||
)
|
||||
|
||||
// Enode represents a host on the network.
|
||||
type Enode struct {
|
||||
node *discv5.Node
|
||||
node *enode.Node
|
||||
}
|
||||
|
||||
// NewEnode parses a node designator.
|
||||
@ -53,8 +53,8 @@ type Enode struct {
|
||||
// and UDP discovery port 30301.
|
||||
//
|
||||
// enode://<hex node id>@10.3.58.6:30303?discport=30301
|
||||
func NewEnode(rawurl string) (enode *Enode, _ error) {
|
||||
node, err := discv5.ParseNode(rawurl)
|
||||
func NewEnode(rawurl string) (*Enode, error) {
|
||||
node, err := enode.Parse(enode.ValidSchemes, rawurl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -62,12 +62,12 @@ func NewEnode(rawurl string) (enode *Enode, _ error) {
|
||||
}
|
||||
|
||||
// Enodes represents a slice of accounts.
|
||||
type Enodes struct{ nodes []*discv5.Node }
|
||||
type Enodes struct{ nodes []*enode.Node }
|
||||
|
||||
// NewEnodes creates a slice of uninitialized enodes.
|
||||
func NewEnodes(size int) *Enodes {
|
||||
return &Enodes{
|
||||
nodes: make([]*discv5.Node, size),
|
||||
nodes: make([]*enode.Node, size),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/p2p/discv5"
|
||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
)
|
||||
|
||||
@ -62,9 +62,13 @@ func GoerliGenesis() string {
|
||||
// FoundationBootnodes returns the enode URLs of the P2P bootstrap nodes operated
|
||||
// by the foundation running the V5 discovery protocol.
|
||||
func FoundationBootnodes() *Enodes {
|
||||
nodes := &Enodes{nodes: make([]*discv5.Node, len(params.MainnetBootnodes))}
|
||||
nodes := &Enodes{nodes: make([]*enode.Node, len(params.MainnetBootnodes))}
|
||||
for i, url := range params.MainnetBootnodes {
|
||||
nodes.nodes[i] = discv5.MustParseNode(url)
|
||||
var err error
|
||||
nodes.nodes[i], err = enode.Parse(enode.ValidSchemes, url)
|
||||
if err != nil {
|
||||
panic("invalid node URL: " + err.Error())
|
||||
}
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
Reference in New Issue
Block a user