From 59c4428d66980c2bd97cd892c6e4d4074b965c49 Mon Sep 17 00:00:00 2001 From: Cyrix126 Date: Thu, 9 Jan 2025 12:11:49 +0100 Subject: [PATCH] feat: keep the algo running even if the public stats are unavailable --- src/app/panels/middle/status/processes.rs | 3 ++- src/helper/xvb/public_stats.rs | 22 ++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/app/panels/middle/status/processes.rs b/src/app/panels/middle/status/processes.rs index 43c89de..ef6877f 100644 --- a/src/app/panels/middle/status/processes.rs +++ b/src/app/panels/middle/status/processes.rs @@ -340,7 +340,8 @@ fn xmrig( fn xvb(ui: &mut Ui, xvb_alive: bool, xvb_api: &Arc>) { // let api = &xvb_api.lock().unwrap().stats_pub; - let enabled = xvb_alive; + // if block height is at 0, the API has not been retrieved correctly. + let enabled = xvb_alive && api.block_height != 0; debug!("Status Tab | Rendering [XvB]"); ui.add_enabled_ui(enabled, |ui| { // for now there is no API ping or /health, so we verify if the field reward_yearly is empty or not. diff --git a/src/helper/xvb/public_stats.rs b/src/helper/xvb/public_stats.rs index c4f0e58..2f1d5a7 100644 --- a/src/helper/xvb/public_stats.rs +++ b/src/helper/xvb/public_stats.rs @@ -98,23 +98,21 @@ impl XvbPubStats { ); // output the error to console // if error already present, no need to print it multiple times. - if process.lock().unwrap().state != ProcessState::Failed { - output_console( - &mut gui_api.lock().unwrap().output, - &format!( - "Failure to retrieve public stats from {}\nWill retry shortly...", - XVB_URL_PUBLIC_API - ), - ProcessName::Xvb, - ); - } + output_console( + &mut gui_api.lock().unwrap().output, + &format!( + "Failure to retrieve public stats from {}\nWill retry shortly...", + XVB_URL_PUBLIC_API + ), + ProcessName::Xvb, + ); // we stop the algo (will be stopped by the check status on next loop) because we can't make the rest work without public stats. (winner in xvb private stats). output_console( &mut gui_api.lock().unwrap().output, - "request to get public API failed", + "request to get public API failed.\nYou won't have any public stats available but the algorithm can continue.", ProcessName::Xvb, ); - process.lock().unwrap().state = ProcessState::Failed; + pub_api.lock().unwrap().stats_pub = XvbPubStats::default(); } } }