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:
@ -72,6 +72,7 @@ type LightEthereum struct {
|
||||
netRPCService *ethapi.PublicNetAPI
|
||||
|
||||
p2pServer *p2p.Server
|
||||
p2pConfig *p2p.Config
|
||||
}
|
||||
|
||||
// New creates an instance of the light client.
|
||||
@ -109,14 +110,11 @@ func New(stack *node.Node, config *eth.Config) (*LightEthereum, error) {
|
||||
bloomIndexer: eth.NewBloomIndexer(chainDb, params.BloomBitsBlocksClient, params.HelperTrieConfirmations),
|
||||
valueTracker: lpc.NewValueTracker(lespayDb, &mclock.System{}, requestList, time.Minute, 1/float64(time.Hour), 1/float64(time.Hour*100), 1/float64(time.Hour*1000)),
|
||||
p2pServer: stack.Server(),
|
||||
p2pConfig: &stack.Config().P2P,
|
||||
}
|
||||
peers.subscribe((*vtSubscription)(leth.valueTracker))
|
||||
|
||||
dnsdisc, err := leth.setupDiscovery()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
leth.serverPool = newServerPool(lespayDb, []byte("serverpool:"), leth.valueTracker, dnsdisc, time.Second, nil, &mclock.System{}, config.UltraLightServers)
|
||||
leth.serverPool = newServerPool(lespayDb, []byte("serverpool:"), leth.valueTracker, time.Second, nil, &mclock.System{}, config.UltraLightServers)
|
||||
peers.subscribe(leth.serverPool)
|
||||
leth.dialCandidates = leth.serverPool.dialIterator
|
||||
|
||||
@ -299,6 +297,11 @@ func (s *LightEthereum) Protocols() []p2p.Protocol {
|
||||
func (s *LightEthereum) Start() error {
|
||||
log.Warn("Light client mode is an experimental feature")
|
||||
|
||||
discovery, err := s.setupDiscovery(s.p2pConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.serverPool.addSource(discovery)
|
||||
s.serverPool.start()
|
||||
// Start bloom request workers.
|
||||
s.wg.Add(bloomServiceThreads)
|
||||
|
Reference in New Issue
Block a user