feat: keep the algo running even if the public stats are unavailable

This commit is contained in:
Cyrix126 2025-01-09 12:11:49 +01:00
parent 12e5e4d8b7
commit 59c4428d66
2 changed files with 12 additions and 13 deletions

View file

@ -340,7 +340,8 @@ fn xmrig(
fn xvb(ui: &mut Ui, xvb_alive: bool, xvb_api: &Arc<Mutex<PubXvbApi>>) { fn xvb(ui: &mut Ui, xvb_alive: bool, xvb_api: &Arc<Mutex<PubXvbApi>>) {
// //
let api = &xvb_api.lock().unwrap().stats_pub; 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]"); debug!("Status Tab | Rendering [XvB]");
ui.add_enabled_ui(enabled, |ui| { 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. // for now there is no API ping or /health, so we verify if the field reward_yearly is empty or not.

View file

@ -98,23 +98,21 @@ impl XvbPubStats {
); );
// output the error to console // output the error to console
// if error already present, no need to print it multiple times. // if error already present, no need to print it multiple times.
if process.lock().unwrap().state != ProcessState::Failed { output_console(
output_console( &mut gui_api.lock().unwrap().output,
&mut gui_api.lock().unwrap().output, &format!(
&format!( "Failure to retrieve public stats from {}\nWill retry shortly...",
"Failure to retrieve public stats from {}\nWill retry shortly...", XVB_URL_PUBLIC_API
XVB_URL_PUBLIC_API ),
), ProcessName::Xvb,
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). // 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( output_console(
&mut gui_api.lock().unwrap().output, &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, ProcessName::Xvb,
); );
process.lock().unwrap().state = ProcessState::Failed; pub_api.lock().unwrap().stats_pub = XvbPubStats::default();
} }
} }
} }