From 489d0c16481a46186b659cab15dde5338ea6e2cb Mon Sep 17 00:00:00 2001 From: Ivan FB <128452529+Ivansete-status@users.noreply.github.com> Date: Mon, 29 Apr 2024 17:47:18 +0200 Subject: [PATCH] waku_node.nim: simplify stop proc (#2645) There is no need to explicitly stop mounted libp2p protocols because they are already being stopped after the switch.stop() is being called --- waku/node/waku_node.nim | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/waku/node/waku_node.nim b/waku/node/waku_node.nim index 6d6f2cdb3..c329f9e28 100644 --- a/waku/node/waku_node.nim +++ b/waku/node/waku_node.nim @@ -1217,13 +1217,6 @@ proc start*(node: WakuNode) {.async.} = info "Node started successfully" proc stop*(node: WakuNode) {.async.} = - if not node.wakuRelay.isNil(): - await node.wakuRelay.stop() - - if not node.wakuMetadata.isNil(): - node.wakuMetadata.stop() - - await node.switch.stop() node.peerManager.stop() if not node.wakuRlnRelay.isNil(): @@ -1235,6 +1228,9 @@ proc stop*(node: WakuNode) {.async.} = if not node.wakuArchive.isNil(): await node.wakuArchive.stopWait() + ## By stopping the switch we are stopping all the underlying mounted protocols + await node.switch.stop() + node.started = false proc isReady*(node: WakuNode): Future[bool] {.async: (raises: [Exception]).} =