Add abstraction for reachable nodes

This commit is contained in:
Arnaud 2026-04-15 10:25:36 +04:00
parent 42ced01893
commit 4a453c53e0
No known key found for this signature in database
GPG Key ID: A6C7C781817146FA
2 changed files with 7 additions and 1 deletions

View File

@ -401,6 +401,12 @@ proc setupAddress*(
of NatStrategy.NatUpnp, NatStrategy.NatPmp:
return setupNat(natConfig.nat, tcpPort, udpPort, clientId)
proc findReachableNodes*(bootstrapNodes: seq[SignedPeerRecord]): seq[SignedPeerRecord] =
## Returns the list of nodes known to be directly reachable.
## Currently returns bootstrap nodes. In the future, any network participant
## confirmed reachable by AutoNAT could be included.
bootstrapNodes
proc nattedAddress*(
natConfig: NatConfig, addrs: seq[MultiAddress], udpPort: Port
): tuple[libp2p, discovery: seq[MultiAddress]] =

View File

@ -111,7 +111,7 @@ proc start*(s: StorageServer) {.async.} =
await s.storageNode.start()
for spr in s.config.bootstrapNodes:
for spr in findReachableNodes(s.config.bootstrapNodes):
try:
let addrs = spr.data.addresses.mapIt(it.address)
await s.storageNode.switch.connect(spr.data.peerId, addrs)