Start discovery after announce address is updated (#536)

* Start discovery after announce address is updated

* Moves switch start-stop to codex.nim. Adjusts timing to solve issue
This commit is contained in:
Ben Bierens 2023-09-04 11:12:20 +02:00 committed by GitHub
parent 545e0d47e1
commit d279eebd69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 10 deletions

View File

@ -113,12 +113,10 @@ proc start*(s: CodexServer) {.async.} =
notice "Starting codex node"
await s.repoStore.start()
s.restServer.start()
s.codexNode.contracts = await bootstrapInteractions(s.config, s.repoStore)
await s.codexNode.start()
s.maintenance.start()
await s.codexNode.switch.start()
let
# TODO: Can't define these as constants, pity
natIpPart = MultiAddress.init("/ip4/" & $s.config.nat & "/")
@ -144,6 +142,10 @@ proc start*(s: CodexServer) {.async.} =
s.codexNode.discovery.updateAnnounceRecord(announceAddrs)
s.codexNode.discovery.updateDhtRecord(s.config.nat, s.config.discoveryPort)
s.codexNode.contracts = await bootstrapInteractions(s.config, s.repoStore)
await s.codexNode.start()
s.restServer.start()
s.runHandle = newFuture[void]("codex.runHandle")
await s.runHandle
@ -152,6 +154,7 @@ proc stop*(s: CodexServer) {.async.} =
await allFuturesThrowing(
s.restServer.stop(),
s.codexNode.switch.stop(),
s.codexNode.stop(),
s.repoStore.stop(),
s.maintenance.stop())

View File

@ -327,9 +327,6 @@ proc new*(
contracts: contracts)
proc start*(node: CodexNodeRef) {.async.} =
if not node.switch.isNil:
await node.switch.start()
if not node.engine.isNil:
await node.engine.start()
@ -406,9 +403,6 @@ proc stop*(node: CodexNodeRef) {.async.} =
if not node.engine.isNil:
await node.engine.stop()
if not node.switch.isNil:
await node.switch.stop()
if not node.erasure.isNil:
await node.erasure.stop()