Add timeout to switch.connect

This commit is contained in:
kdeme 2020-06-02 13:55:49 +02:00 committed by zah
parent 1a6b83a15f
commit 06f025b228

View File

@ -652,7 +652,7 @@ proc dialPeer*(node: Eth2Node, peerInfo: PeerInfo) {.async.} =
logScope: peer = $peerInfo
debug "Connecting to peer"
await node.switch.connect(peerInfo)
if await withTimeout(node.switch.connect(peerInfo), 10.seconds):
var peer = node.getPeer(peerInfo)
peer.wasDialed = true
@ -666,6 +666,8 @@ proc dialPeer*(node: Eth2Node, peerInfo: PeerInfo) {.async.} =
inc libp2p_successful_dials
debug "Network handshakes completed"
else:
debug "Connection timed out"
proc runDiscoveryLoop*(node: Eth2Node) {.async.} =
debug "Starting discovery loop"