From 5b7ff0513813fa6fb01d2b4ca396c760ea3e9897 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Fri, 5 Jun 2026 18:17:25 +0400 Subject: [PATCH] Connect boostrap nodes concurrently --- storage/storage.nim | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/storage/storage.nim b/storage/storage.nim index 19488ad5..af4e378b 100644 --- a/storage/storage.nim +++ b/storage/storage.nim @@ -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.