mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-12-22 14:49:21 +00:00
fix: detect when p2pool is synced even without restart
This commit is contained in:
parent
536af2ce2a
commit
dce3b93aef
2 changed files with 5 additions and 21 deletions
|
@ -812,23 +812,9 @@ impl PubP2poolApi {
|
||||||
let (payouts_new, xmr_new) = Self::calc_payouts_and_xmr(&output_parse);
|
let (payouts_new, xmr_new) = Self::calc_payouts_and_xmr(&output_parse);
|
||||||
// Check for "SYNCHRONIZED" only if we aren't already.
|
// Check for "SYNCHRONIZED" only if we aren't already.
|
||||||
if lock!(process).state == ProcessState::Syncing {
|
if lock!(process).state == ProcessState::Syncing {
|
||||||
// How many times the word was captured.
|
// look for depth 0
|
||||||
let synchronized_captures = P2POOL_REGEX.synchronized.find_iter(&output_parse).count();
|
|
||||||
|
|
||||||
// If P2Pool receives shares before syncing, it will start mining on its own sidechain.
|
if P2POOL_REGEX.depth_0.is_match(&output_parse) {
|
||||||
// In this instance, we technically are "synced" on block 1 and P2Pool will print "SYNCHRONIZED"
|
|
||||||
// although, that doesn't necessarily mean we're synced on main/mini-chain.
|
|
||||||
//
|
|
||||||
// So, if we find a `next block = 1`, that means we
|
|
||||||
// must look for at least 2 instances of "SYNCHRONIZED",
|
|
||||||
// one for the sidechain, one for main/mini.
|
|
||||||
if P2POOL_REGEX.next_height_1.is_match(&output_parse) {
|
|
||||||
if synchronized_captures > 1 {
|
|
||||||
lock!(process).state = ProcessState::Alive;
|
|
||||||
}
|
|
||||||
} else if synchronized_captures > 0 {
|
|
||||||
// if there is no `next block = 1`, fallback to
|
|
||||||
// just finding 1 instance of "SYNCHRONIZED".
|
|
||||||
lock!(process).state = ProcessState::Alive;
|
lock!(process).state = ProcessState::Alive;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,8 +90,7 @@ pub struct P2poolRegex {
|
||||||
pub block: Regex,
|
pub block: Regex,
|
||||||
pub block_int: Regex,
|
pub block_int: Regex,
|
||||||
pub block_comma: Regex,
|
pub block_comma: Regex,
|
||||||
pub synchronized: Regex,
|
pub depth_0: Regex,
|
||||||
pub next_height_1: Regex,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl P2poolRegex {
|
impl P2poolRegex {
|
||||||
|
@ -105,8 +104,7 @@ impl P2poolRegex {
|
||||||
block: Regex::new("block [0-9]{7}").unwrap(), // Monero blocks will be 7 digits for... the next 10,379 years
|
block: Regex::new("block [0-9]{7}").unwrap(), // Monero blocks will be 7 digits for... the next 10,379 years
|
||||||
block_int: Regex::new("[0-9]{7}").unwrap(),
|
block_int: Regex::new("[0-9]{7}").unwrap(),
|
||||||
block_comma: Regex::new("[0-9],[0-9]{3},[0-9]{3}").unwrap(),
|
block_comma: Regex::new("[0-9],[0-9]{3},[0-9]{3}").unwrap(),
|
||||||
synchronized: Regex::new("SYNCHRONIZED").unwrap(),
|
depth_0: Regex::new("depth = 0").unwrap(),
|
||||||
next_height_1: Regex::new("next height = 1").unwrap(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,7 +303,7 @@ mod test {
|
||||||
assert_eq!(r.block.find(text).unwrap().as_str(), "block 1111111");
|
assert_eq!(r.block.find(text).unwrap().as_str(), "block 1111111");
|
||||||
assert_eq!(r.block_int.find(text).unwrap().as_str(), "1111111");
|
assert_eq!(r.block_int.find(text).unwrap().as_str(), "1111111");
|
||||||
assert_eq!(r.block_comma.find(text2).unwrap().as_str(), "1,111,111");
|
assert_eq!(r.block_comma.find(text2).unwrap().as_str(), "1,111,111");
|
||||||
assert_eq!(r.synchronized.find(text3).unwrap().as_str(), "SYNCHRONIZED");
|
assert_eq!(r.depth_0.find(text3).unwrap().as_str(), "depth = 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue