feat: put p2pool process to syncing if node doesn't respond anymore

This commit is contained in:
Cyrix126 2024-10-06 14:55:29 +02:00
parent 06f8d9bc65
commit 536af2ce2a
3 changed files with 18 additions and 0 deletions

View file

@ -31,6 +31,10 @@ impl P2pool {
// saves me the hassle of wrapping [state: State] completely // saves me the hassle of wrapping [state: State] completely
// and [.lock().unwrap()]ing it everywhere. // and [.lock().unwrap()]ing it everywhere.
// Two atomic bools = enough to represent this data // Two atomic bools = enough to represent this data
// local or remote
// disable remote if local is checked.
debug!("P2Pool Tab | Running [auto-select] check"); debug!("P2Pool Tab | Running [auto-select] check");
if self.auto_select { if self.auto_select {
let mut ping = lock!(ping); let mut ping = lock!(ping);

View file

@ -13,6 +13,7 @@ use crate::regex::contains_end_status;
use crate::regex::contains_statuscommand; use crate::regex::contains_statuscommand;
use crate::regex::contains_yourhashrate; use crate::regex::contains_yourhashrate;
use crate::regex::contains_yourshare; use crate::regex::contains_yourshare;
use crate::regex::contains_zmq_connection_lost;
use crate::regex::estimated_hr; use crate::regex::estimated_hr;
use crate::regex::nb_current_shares; use crate::regex::nb_current_shares;
use crate::regex::P2POOL_REGEX; use crate::regex::P2POOL_REGEX;
@ -831,6 +832,14 @@ impl PubP2poolApi {
lock!(process).state = ProcessState::Alive; 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] // 3. Throw away [output_parse]
output_parse.clear(); output_parse.clear();
drop(output_parse); drop(output_parse);

View file

@ -224,6 +224,11 @@ pub fn contains_timeout(l: &str) -> bool {
static LINE_SHARE: Lazy<Regex> = Lazy::new(|| Regex::new(r"timeout").unwrap()); static LINE_SHARE: Lazy<Regex> = Lazy::new(|| Regex::new(r"timeout").unwrap());
LINE_SHARE.is_match(l) LINE_SHARE.is_match(l)
} }
pub fn contains_zmq_connection_lost(l: &str) -> bool {
static LINE_SHARE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"ZMQReader failed to connect to").unwrap());
LINE_SHARE.is_match(l)
}
pub fn contains_error(l: &str) -> bool { pub fn contains_error(l: &str) -> bool {
static LINE_SHARE: Lazy<Regex> = Lazy::new(|| Regex::new(r"error").unwrap()); static LINE_SHARE: Lazy<Regex> = Lazy::new(|| Regex::new(r"error").unwrap());
LINE_SHARE.is_match(l) LINE_SHARE.is_match(l)