Merge branch 'peerinfo' into devel

This commit is contained in:
Ștefan Talpalaru 2020-03-30 19:55:24 +02:00
commit e37c12b810
No known key found for this signature in database
GPG Key ID: CBF7934204F1B6F9
1 changed files with 7 additions and 4 deletions

View File

@ -663,13 +663,16 @@ proc runDiscoveryLoop*(node: Eth2Node) {.async.} =
try:
let discoveredPeers =
node.discovery.randomNodes(node.wantedPeers - currentPeerCount)
debug "Discovered peers", peer = $discoveredPeers
for peer in discoveredPeers:
try:
let peerInfo = peer.record.toTypedRecord.toPeerInfo
if peerInfo != nil and peerInfo.id notin node.switch.connections:
# TODO do this in parallel
await node.dialPeer(peerInfo)
if peerInfo != nil:
if peerInfo.id notin node.switch.connections:
debug "Discovered new peer", peer = $peer
# TODO do this in parallel
await node.dialPeer(peerInfo)
else:
peerInfo.close()
except CatchableError as err:
debug "Failed to connect to peer", peer = $peer, err = err.msg
except CatchableError as err: