mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-21 20:10:36 +00:00
Don't wait for 10 seconds when connecting to the network
This commit is contained in:
parent
55886ff0ac
commit
880b981a0a
@ -156,7 +156,7 @@ when networkBackend in [libp2p, libp2pDaemon]:
|
||||
# are running behind a NAT).
|
||||
var switch = newStandardSwitch(some keys.seckey, hostAddress,
|
||||
triggerSelf = true, gossip = false)
|
||||
result = Eth2Node.init(conf, switch, keys.seckey.skkey)
|
||||
result = Eth2Node.init(conf, switch, keys.seckey.asEthKey)
|
||||
else:
|
||||
let keyFile = conf.ensureNetworkIdFile
|
||||
|
||||
@ -227,10 +227,13 @@ when networkBackend in [libp2p, libp2pDaemon]:
|
||||
node.addKnownPeer bootstrapNode
|
||||
await node.start()
|
||||
|
||||
await sleepAsync(10.seconds)
|
||||
if bootstrapEnrs.len > 0 and libp2p_successful_dials.value == 0:
|
||||
fatal "Failed to connect to any bootstrap node. Quitting", bootstrapEnrs
|
||||
quit 1
|
||||
proc checkIfConnectedToBootstrapNode {.async.} =
|
||||
await sleepAsync(10.seconds)
|
||||
if bootstrapEnrs.len > 0 and libp2p_successful_dials.value == 0:
|
||||
fatal "Failed to connect to any bootstrap node. Quitting", bootstrapEnrs
|
||||
quit 1
|
||||
|
||||
traceAsyncErrors checkIfConnectedToBootstrapNode()
|
||||
|
||||
proc saveConnectionAddressFile*(node: Eth2Node, filename: string) =
|
||||
when networkBackend == libp2p:
|
||||
|
@ -182,12 +182,15 @@ proc toPeerInfo(r: Option[enr.TypedRecord]): PeerInfo =
|
||||
return r.get.toPeerInfo
|
||||
|
||||
proc dialPeer*(node: Eth2Node, peerInfo: PeerInfo) {.async.} =
|
||||
debug "Dialing peer", peer = $peerInfo
|
||||
logScope: peer = $peerInfo
|
||||
|
||||
debug "Dialing peer"
|
||||
discard await node.switch.dial(peerInfo)
|
||||
var peer = node.getPeer(peerInfo)
|
||||
peer.wasDialed = true
|
||||
await initializeConnection(peer)
|
||||
inc libp2p_successful_dials
|
||||
debug "Network handshakes completed"
|
||||
|
||||
proc runDiscoveryLoop*(node: Eth2Node) {.async.} =
|
||||
debug "Starting discovery loop"
|
||||
|
Loading…
x
Reference in New Issue
Block a user