mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-11 14:54:12 +00:00
Add timeout to switch.connect
This commit is contained in:
parent
1a6b83a15f
commit
06f025b228
@ -652,20 +652,22 @@ proc dialPeer*(node: Eth2Node, peerInfo: PeerInfo) {.async.} =
|
|||||||
logScope: peer = $peerInfo
|
logScope: peer = $peerInfo
|
||||||
|
|
||||||
debug "Connecting to peer"
|
debug "Connecting to peer"
|
||||||
await node.switch.connect(peerInfo)
|
if await withTimeout(node.switch.connect(peerInfo), 10.seconds):
|
||||||
var peer = node.getPeer(peerInfo)
|
var peer = node.getPeer(peerInfo)
|
||||||
peer.wasDialed = true
|
peer.wasDialed = true
|
||||||
|
|
||||||
#let msDial = newMultistream()
|
#let msDial = newMultistream()
|
||||||
#let conn = node.switch.connections.getOrDefault(peerInfo.id)
|
#let conn = node.switch.connections.getOrDefault(peerInfo.id)
|
||||||
#let ls = await msDial.list(conn)
|
#let ls = await msDial.list(conn)
|
||||||
#debug "Supported protocols", ls
|
#debug "Supported protocols", ls
|
||||||
|
|
||||||
debug "Initializing connection"
|
debug "Initializing connection"
|
||||||
await initializeConnection(peer)
|
await initializeConnection(peer)
|
||||||
|
|
||||||
inc libp2p_successful_dials
|
inc libp2p_successful_dials
|
||||||
debug "Network handshakes completed"
|
debug "Network handshakes completed"
|
||||||
|
else:
|
||||||
|
debug "Connection timed out"
|
||||||
|
|
||||||
proc runDiscoveryLoop*(node: Eth2Node) {.async.} =
|
proc runDiscoveryLoop*(node: Eth2Node) {.async.} =
|
||||||
debug "Starting discovery loop"
|
debug "Starting discovery loop"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user