From 536af2ce2a20f026010d4b5f5c9e6a425b1c1043 Mon Sep 17 00:00:00 2001 From: Cyrix126 Date: Sun, 6 Oct 2024 14:55:29 +0200 Subject: [PATCH] feat: put p2pool process to syncing if node doesn't respond anymore --- src/app/panels/middle/p2pool/simple.rs | 4 ++++ src/helper/p2pool.rs | 9 +++++++++ src/utils/regex.rs | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/src/app/panels/middle/p2pool/simple.rs b/src/app/panels/middle/p2pool/simple.rs index 34943a2..82404e8 100644 --- a/src/app/panels/middle/p2pool/simple.rs +++ b/src/app/panels/middle/p2pool/simple.rs @@ -31,6 +31,10 @@ impl P2pool { // saves me the hassle of wrapping [state: State] completely // and [.lock().unwrap()]ing it everywhere. // Two atomic bools = enough to represent this data + + // local or remote + + // disable remote if local is checked. debug!("P2Pool Tab | Running [auto-select] check"); if self.auto_select { let mut ping = lock!(ping); diff --git a/src/helper/p2pool.rs b/src/helper/p2pool.rs index ff010bd..da1e658 100644 --- a/src/helper/p2pool.rs +++ b/src/helper/p2pool.rs @@ -13,6 +13,7 @@ use crate::regex::contains_end_status; use crate::regex::contains_statuscommand; use crate::regex::contains_yourhashrate; use crate::regex::contains_yourshare; +use crate::regex::contains_zmq_connection_lost; use crate::regex::estimated_hr; use crate::regex::nb_current_shares; use crate::regex::P2POOL_REGEX; @@ -831,6 +832,14 @@ impl PubP2poolApi { lock!(process).state = ProcessState::Alive; } } + // check if zmq server still alive + if lock!(process).state == ProcessState::Alive + && contains_zmq_connection_lost(&output_parse) + { + // node zmq is not responding, p2pool is not ready + lock!(process).state = ProcessState::Syncing; + } + // 3. Throw away [output_parse] output_parse.clear(); drop(output_parse); diff --git a/src/utils/regex.rs b/src/utils/regex.rs index ac747f9..130e674 100644 --- a/src/utils/regex.rs +++ b/src/utils/regex.rs @@ -224,6 +224,11 @@ pub fn contains_timeout(l: &str) -> bool { static LINE_SHARE: Lazy = Lazy::new(|| Regex::new(r"timeout").unwrap()); LINE_SHARE.is_match(l) } +pub fn contains_zmq_connection_lost(l: &str) -> bool { + static LINE_SHARE: Lazy = + Lazy::new(|| Regex::new(r"ZMQReader failed to connect to").unwrap()); + LINE_SHARE.is_match(l) +} pub fn contains_error(l: &str) -> bool { static LINE_SHARE: Lazy = Lazy::new(|| Regex::new(r"error").unwrap()); LINE_SHARE.is_match(l)