From 02717a6354573591330721558750c425e55d7308 Mon Sep 17 00:00:00 2001 From: kdeme Date: Mon, 2 Mar 2020 19:15:13 +0100 Subject: [PATCH] Use randomNodes from discv5 instead of lookup --- beacon_chain/eth2_discovery.nim | 2 +- beacon_chain/libp2p_backend.nim | 3 +-- vendor/nim-eth | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/beacon_chain/eth2_discovery.nim b/beacon_chain/eth2_discovery.nim index 5bb99b511..c66b51f32 100644 --- a/beacon_chain/eth2_discovery.nim +++ b/beacon_chain/eth2_discovery.nim @@ -12,7 +12,7 @@ type PublicKey = keys.PublicKey export - Eth2DiscoveryProtocol, open, start, close, result + Eth2DiscoveryProtocol, open, close, result proc new*(T: type Eth2DiscoveryProtocol, conf: BeaconNodeConf, diff --git a/beacon_chain/libp2p_backend.nim b/beacon_chain/libp2p_backend.nim index 52a7dde5d..f48bd76c0 100644 --- a/beacon_chain/libp2p_backend.nim +++ b/beacon_chain/libp2p_backend.nim @@ -244,7 +244,7 @@ proc runDiscoveryLoop*(node: Eth2Node) {.async.} = libp2p_peers.set currentPeerCount.int64 if currentPeerCount < node.wantedPeers: try: - let discoveredPeers = await node.discovery.lookupRandom() + let discoveredPeers = node.discovery.randomNodes(node.wantedPeers - currentPeerCount) debug "Discovered peers", peer = $discoveredPeers for peer in discoveredPeers: try: @@ -281,7 +281,6 @@ template addKnownPeer*(node: Eth2Node, peer: ENode|enr.Record) = proc start*(node: Eth2Node) {.async.} = node.discovery.open() - node.discovery.start() node.libp2pTransportLoops = await node.switch.start() traceAsyncErrors node.runDiscoveryLoop() diff --git a/vendor/nim-eth b/vendor/nim-eth index e89e59aa5..bc6c98191 160000 --- a/vendor/nim-eth +++ b/vendor/nim-eth @@ -1 +1 @@ -Subproject commit e89e59aa5952bf663b3b1fd705cdd6139f006672 +Subproject commit bc6c9819166fd2aba242aee06bd7ea59725ebcac