Connect boostrap nodes concurrently

This commit is contained in:
Arnaud 2026-06-05 18:17:25 +04:00
parent da1066c32a
commit 5b7ff05138
No known key found for this signature in database
GPG Key ID: A6C7C781817146FA

View File

@ -126,8 +126,11 @@ proc start*(s: StorageServer) {.async.} =
await s.storageNode.start()
# Connect to the bootstrap nodes in order to have connected peers
# for Autonat.
for spr in findReachableNodes(s.bootstrapNodes):
# for Autonat. The dials are run concurrently in case of
# a dead bootstrap node that could timeout.
proc connectBootstrapNode(
spr: SignedPeerRecord
) {.async: (raises: [CancelledError]).} =
try:
let addrs = spr.data.addresses.mapIt(it.address)
await s.storageNode.switch.connect(spr.data.peerId, addrs)
@ -136,6 +139,8 @@ proc start*(s: StorageServer) {.async.} =
except CatchableError as e:
warn "Cannot connect to bootstrap node", error = e.msg
await allFutures(findReachableNodes(s.bootstrapNodes).mapIt(connectBootstrapNode(it)))
# Start AutoNAT here (we own it, it is not in switch.services) so its first
# probe targets the now-connected bootstrap peers instead of firing at
# switch.start on no peers.