refactor(networking): wait for all futures together in connectToNodes (#1471)

* refactor(networking): wait for all futures together in connectToNodes

* refactor(networking): await fix style
This commit is contained in:
Alvaro Revuelta 2023-01-09 21:45:50 +01:00 committed by GitHub
parent 2e92c4f31a
commit 37973586a9

View File

@ -269,10 +269,13 @@ proc connectToNodes*(pm: PeerManager,
source = "api") {.async.} =
info "connectToNodes", len = nodes.len
var futConns: seq[Future[Option[Connection]]]
for node in nodes:
let node = when node is string: parseRemotePeerInfo(node)
else: node
discard await pm.dialPeer(RemotePeerInfo(node), proto, dialTimeout, source)
futConns.add(pm.dialPeer(RemotePeerInfo(node), proto, dialTimeout, source))
await allFutures(futConns)
# The issue seems to be around peers not being fully connected when
# trying to subscribe. So what we do is sleep to guarantee nodes are