From 5a78018b7564915cb9df6cec585115608e99f056 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Thu, 30 Oct 2025 05:51:44 +0100 Subject: [PATCH] Prevent double start issue --- codex/codex.nim | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/codex/codex.nim b/codex/codex.nim index b023e8ea..682fe9b5 100644 --- a/codex/codex.nim +++ b/codex/codex.nim @@ -57,6 +57,7 @@ type repoStore: RepoStore maintenance: BlockMaintainer taskpool: Taskpool + isStarted: bool CodexPrivateKey* = libp2p.PrivateKey # alias EthWallet = ethers.Wallet @@ -168,6 +169,10 @@ proc bootstrapInteractions(s: CodexServer): Future[void] {.async.} = s.codexNode.contracts = (client, host, validator) proc start*(s: CodexServer) {.async.} = + if s.isStarted: + warn "Codex server already started, skipping" + return + trace "Starting codex node", config = $s.config await s.repoStore.start() @@ -188,7 +193,13 @@ proc start*(s: CodexServer) {.async.} = if s.restServer != nil: s.restServer.start() + s.isStarted = true + proc stop*(s: CodexServer) {.async.} = + if not s.isStarted: + warn "Codex is not started" + return + notice "Stopping codex node" var futures =