helper: add check for p2pool synchronized

This commit is contained in:
hinto.janai 2023-04-14 11:29:45 -04:00
parent 8300630875
commit e425388dc8
No known key found for this signature in database
GPG key ID: D47CE05FA175A499
2 changed files with 9 additions and 1 deletions

2
Cargo.lock generated
View file

@ -1951,7 +1951,7 @@ dependencies = [
[[package]]
name = "gupax"
version = "1.2.0"
version = "1.2.1"
dependencies = [
"anyhow",
"arti-client",

View file

@ -1254,6 +1254,7 @@ pub struct PubP2poolApi {
pub xmr_hour: f64,
pub xmr_day: f64,
pub xmr_month: f64,
pub synchronized: bool,
// Local API
pub hashrate_15m: HumanNumber,
pub hashrate_1h: HumanNumber,
@ -1312,6 +1313,7 @@ impl PubP2poolApi {
xmr_hour: 0.0,
xmr_day: 0.0,
xmr_month: 0.0,
synchronized: false,
hashrate_15m: HumanNumber::unknown(),
hashrate_1h: HumanNumber::unknown(),
hashrate_24h: HumanNumber::unknown(),
@ -1385,6 +1387,12 @@ impl PubP2poolApi {
// 2. Parse the full STDOUT
let mut output_parse = lock!(output_parse);
let (payouts_new, xmr_new) = Self::calc_payouts_and_xmr(&output_parse, regex);
// Check for "SYNCHRONIZED" only if we aren't already.
if !lock!(public).synchronized {
if regex.synchronized.is_match(&output_parse) {
lock!(public).synchronized = true;
}
}
// 3. Throw away [output_parse]
output_parse.clear();
drop(output_parse);