mirror of https://github.com/status-im/nim-eth.git
Add option to `connectToNetwork` return without waiting for peers
The new sync code wants to start without waiting. We can `discard` the async result but there is no need for a background task polling and running a timer for no clear benefit. Signed-off-by: Jamie Lokier <jamie@shareable.org>
This commit is contained in:
parent
9a28ed7ef5
commit
83e5638212
|
@ -93,7 +93,8 @@ proc startListening*(node: EthereumNode) {.raises: [CatchableError, Defect].} =
|
|||
proc connectToNetwork*(node: EthereumNode,
|
||||
bootstrapNodes: seq[ENode],
|
||||
startListening = true,
|
||||
enableDiscovery = true) {.async.} =
|
||||
enableDiscovery = true,
|
||||
waitForPeers = true) {.async.} =
|
||||
doAssert node.connectionState == ConnectionState.None
|
||||
|
||||
node.connectionState = Connecting
|
||||
|
@ -112,7 +113,7 @@ proc connectToNetwork*(node: EthereumNode,
|
|||
else:
|
||||
info "Discovery disabled"
|
||||
|
||||
while node.peerPool.connectedNodes.len == 0:
|
||||
while node.peerPool.connectedNodes.len == 0 and waitForPeers:
|
||||
trace "Waiting for more peers", peers = node.peerPool.connectedNodes.len
|
||||
await sleepAsync(500.milliseconds)
|
||||
|
||||
|
|
Loading…
Reference in New Issue