diff --git a/codex/codex.nim b/codex/codex.nim index b77a6508..9a050de1 100644 --- a/codex/codex.nim +++ b/codex/codex.nim @@ -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()) diff --git a/codex/node.nim b/codex/node.nim index 06b4520b..d7f799c2 100644 --- a/codex/node.nim +++ b/codex/node.nim @@ -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()