Use randomNodes from discv5 instead of lookup
This commit is contained in:
parent
91f87b55b4
commit
02717a6354
|
@ -12,7 +12,7 @@ type
|
||||||
PublicKey = keys.PublicKey
|
PublicKey = keys.PublicKey
|
||||||
|
|
||||||
export
|
export
|
||||||
Eth2DiscoveryProtocol, open, start, close, result
|
Eth2DiscoveryProtocol, open, close, result
|
||||||
|
|
||||||
proc new*(T: type Eth2DiscoveryProtocol,
|
proc new*(T: type Eth2DiscoveryProtocol,
|
||||||
conf: BeaconNodeConf,
|
conf: BeaconNodeConf,
|
||||||
|
|
|
@ -244,7 +244,7 @@ proc runDiscoveryLoop*(node: Eth2Node) {.async.} =
|
||||||
libp2p_peers.set currentPeerCount.int64
|
libp2p_peers.set currentPeerCount.int64
|
||||||
if currentPeerCount < node.wantedPeers:
|
if currentPeerCount < node.wantedPeers:
|
||||||
try:
|
try:
|
||||||
let discoveredPeers = await node.discovery.lookupRandom()
|
let discoveredPeers = node.discovery.randomNodes(node.wantedPeers - currentPeerCount)
|
||||||
debug "Discovered peers", peer = $discoveredPeers
|
debug "Discovered peers", peer = $discoveredPeers
|
||||||
for peer in discoveredPeers:
|
for peer in discoveredPeers:
|
||||||
try:
|
try:
|
||||||
|
@ -281,7 +281,6 @@ template addKnownPeer*(node: Eth2Node, peer: ENode|enr.Record) =
|
||||||
|
|
||||||
proc start*(node: Eth2Node) {.async.} =
|
proc start*(node: Eth2Node) {.async.} =
|
||||||
node.discovery.open()
|
node.discovery.open()
|
||||||
node.discovery.start()
|
|
||||||
node.libp2pTransportLoops = await node.switch.start()
|
node.libp2pTransportLoops = await node.switch.start()
|
||||||
traceAsyncErrors node.runDiscoveryLoop()
|
traceAsyncErrors node.runDiscoveryLoop()
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit e89e59aa5952bf663b3b1fd705cdd6139f006672
|
Subproject commit bc6c9819166fd2aba242aee06bd7ea59725ebcac
|
Loading…
Reference in New Issue