mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-10-29 20:47:48 +00:00
Revert "fix: detect when p2pool is synced even without restart"
This reverts commit dce3b93aef
.
This commit is contained in:
parent
18513b758f
commit
7d9724ea24
2 changed files with 21 additions and 9 deletions
|
@ -843,16 +843,25 @@ 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 process.state == ProcessState::Syncing {
|
if process.state == ProcessState::Syncing {
|
||||||
// look for depth 0
|
// How many times the word was captured.
|
||||||
|
let synchronized_captures = P2POOL_REGEX.synchronized.find_iter(&output_parse).count();
|
||||||
|
|
||||||
if P2POOL_REGEX.depth_0.is_match(&output_parse) {
|
// If P2Pool receives shares before syncing, it will start mining on its own sidechain.
|
||||||
|
// 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 {
|
||||||
process.state = ProcessState::Alive;
|
process.state = ProcessState::Alive;
|
||||||
}
|
}
|
||||||
|
} else if synchronized_captures > 0 {
|
||||||
|
// if there is no `next block = 1`, fallback to
|
||||||
|
// just finding 1 instance of "SYNCHRONIZED".
|
||||||
|
process.state = ProcessState::Alive;
|
||||||
}
|
}
|
||||||
// check if zmq server still alive
|
|
||||||
if process.state == ProcessState::Alive && contains_zmq_connection_lost(&output_parse) {
|
|
||||||
// node zmq is not responding, p2pool is not ready
|
|
||||||
process.state = ProcessState::Syncing;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Throw away [output_parse]
|
// 3. Throw away [output_parse]
|
||||||
|
|
|
@ -90,7 +90,8 @@ 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 depth_0: Regex,
|
pub synchronized: Regex,
|
||||||
|
pub next_height_1: Regex,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl P2poolRegex {
|
impl P2poolRegex {
|
||||||
|
@ -104,7 +105,8 @@ 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(),
|
||||||
depth_0: Regex::new("depth = 0").unwrap(),
|
synchronized: Regex::new("SYNCHRONIZED").unwrap(),
|
||||||
|
next_height_1: Regex::new("next height = 1").unwrap(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,6 +299,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");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue