mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-06-27 21:09:28 +00:00
Cleanup
This commit is contained in:
parent
dcdc9d0450
commit
540d8440dc
@ -203,8 +203,8 @@ proc announceDirectAddrs*(
|
||||
d.protocol.updateRecord(spr).expect("Should update SPR")
|
||||
|
||||
proc announceRelayAddrs*(d: Discovery, addrs: openArray[MultiAddress]) =
|
||||
## Updates only announce addresses
|
||||
## When using relay, the DHT routing record is not updated to not pollute the DHT.
|
||||
## Updates the announce addresses and the SPR with the relay circuit addresses.
|
||||
## Unlike announceDirectAddrs, no UDP address is derived so dhtAddrs is left untouched.
|
||||
d.announceAddrs = @addrs
|
||||
info "Updating announce record", addrs = d.announceAddrs
|
||||
d.providerRecord = SignedPeerRecord
|
||||
|
||||
@ -48,11 +48,6 @@ import ./utils/natutils
|
||||
logScope:
|
||||
topics = "storage node"
|
||||
|
||||
const StorageTransportFlags = {ServerFlags.ReuseAddr, ServerFlags.TcpNoDelay}
|
||||
|
||||
proc tcpTransportBuilder(config: TransportConfig): Transport {.gcsafe, raises: [].} =
|
||||
TcpTransport.new(StorageTransportFlags, config.upgr)
|
||||
|
||||
type
|
||||
StorageServer* = ref object
|
||||
config: StorageConf
|
||||
@ -144,8 +139,8 @@ proc start*(s: StorageServer) {.async.} =
|
||||
|
||||
await allFutures(findReachableNodes(s.bootstrapNodes).mapIt(connectBootstrapNode(it)))
|
||||
|
||||
# AutoNAT is not in switch.services: start it after the bootstrap dials
|
||||
# so its first probe has peers to ask.
|
||||
# AutoNAT is not in switch.services because we want to start it
|
||||
# after the bootstrap connections to have connected peers for the first probe.
|
||||
if s.autonatService.isSome:
|
||||
await s.autonatService.get.start(s.storageNode.switch)
|
||||
|
||||
@ -238,10 +233,8 @@ proc new*(
|
||||
config: StorageConf,
|
||||
privateKey: StoragePrivateKey,
|
||||
logFile: Option[IoHandle] = IoHandle.none,
|
||||
transportBuilder: TransportBuilder = tcpTransportBuilder,
|
||||
): StorageServer =
|
||||
## create StorageServer including setting up datastore, repostore, etc.
|
||||
## ``transportBuilder`` defaults to TCP; tests inject a simulated NAT transport.
|
||||
|
||||
if err =? config.validateAutonatConfig().errorOption:
|
||||
raise newException(StorageError, err.msg)
|
||||
@ -324,7 +317,9 @@ proc new*(
|
||||
# addresses.
|
||||
switchBuilder = switchBuilder.withAddressPolicy(dialableAddressPolicy)
|
||||
|
||||
let switch = switchBuilder.withTransport(transportBuilder).build()
|
||||
let switch = switchBuilder
|
||||
.withTcpTransport({ServerFlags.ReuseAddr, ServerFlags.TcpNoDelay})
|
||||
.build()
|
||||
|
||||
var taskPool: Taskpool
|
||||
|
||||
|
||||
@ -155,12 +155,13 @@ asyncchecksuite "NAT reaction - port mapping":
|
||||
check disc.protocol.clientMode
|
||||
|
||||
test "handleNatStatus stops relay and exits client mode when mapping is created and node is Reachable":
|
||||
let dialBack = MultiAddress.init("/ip4/1.2.3.4/tcp/8080").expect("valid")
|
||||
let mapper = MockNatPortMapper(mappedPorts: none((Port, Port, MappingProtocol)))
|
||||
|
||||
disc.protocol.clientMode = true
|
||||
autorelayservice.setup(autoRelay, sw)
|
||||
await mapper.handleNatStatus(
|
||||
Reachable, Opt.none(MultiAddress), discoveryPort, disc, sw, autoRelay
|
||||
Reachable, Opt.some(dialBack), discoveryPort, disc, sw, autoRelay
|
||||
)
|
||||
|
||||
check not autoRelay.isRunning
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user