Skip to content

Commit

Permalink
Start discovery after announce address is updated (#536)
Browse files Browse the repository at this point in the history
* Start discovery after announce address is updated

* Moves switch start-stop to codex.nim. Adjusts timing to solve issue
  • Loading branch information
benbierens authored Sep 4, 2023
1 parent 545e0d4 commit d279eeb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
11 changes: 7 additions & 4 deletions codex/codex.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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 & "/")
Expand All @@ -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

Expand All @@ -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())
Expand Down
6 changes: 0 additions & 6 deletions codex/node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit d279eeb

Please sign in to comment.