From 14b001a16738b08d574d155852f24d403f7ce1c6 Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Quiros Date: Fri, 30 Sep 2022 17:25:03 +0200 Subject: [PATCH] Use static instead of const for global flag --- waku/src/node_management/mod.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/waku/src/node_management/mod.rs b/waku/src/node_management/mod.rs index b0a9e8b..e273c93 100644 --- a/waku/src/node_management/mod.rs +++ b/waku/src/node_management/mod.rs @@ -12,7 +12,7 @@ use crate::general::Result; pub use config::WakuNodeConfig; /// Shared flag to check if a waku node is already running in the current process -const WAKU_NODE_RUNNING: Mutex = Mutex::new(false); +static WAKU_NODE_RUNNING: Mutex = Mutex::new(false); /// Marker trait to disallow undesired waku node states in the handle pub trait WakuNodeState {} @@ -40,8 +40,9 @@ impl WakuNodeHandle { impl WakuNodeHandle { pub fn start(self) -> Result> { - let flag = WAKU_NODE_RUNNING; - let mut node_running = flag.lock().expect("Access to the mutex at some point"); + let mut node_running = WAKU_NODE_RUNNING + .lock() + .expect("Access to the mutex at some point"); if *node_running { return Err("Waku node is already running".into()); }