From a0b37540f1e3dc1814ad7eda349c0f27e881f220 Mon Sep 17 00:00:00 2001 From: mostafaei2002 Date: Sun, 16 Jun 2024 22:15:05 +0330 Subject: [PATCH] fix: change xvb_24h metric into H/s and refactor --- src/helper/xvb/algorithm.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/helper/xvb/algorithm.rs b/src/helper/xvb/algorithm.rs index f2c9e1c..1c8203a 100644 --- a/src/helper/xvb/algorithm.rs +++ b/src/helper/xvb/algorithm.rs @@ -92,6 +92,8 @@ impl<'a> Algorithm<'a> { time_donated: &'a Arc>, rig: &'a str, ) -> Self { + info!("XvB Process | Starting Algorithm - Algorithm State:",); + let hashrate_xmrig = { if lock!(gui_api_xmrig).hashrate_raw_15m > 0.0 { lock!(gui_api_xmrig).hashrate_raw_15m @@ -104,8 +106,8 @@ impl<'a> Algorithm<'a> { let address = state_p2pool.address.clone(); - let xvb_24h_avg = lock!(gui_api_xvb).stats_priv.donor_24hr_avg; - let xvb_1h_avg = lock!(gui_api_xvb).stats_priv.donor_1hr_avg; + let xvb_24h_avg = lock!(gui_api_xvb).stats_priv.donor_24hr_avg * 1000.0; + let xvb_1h_avg = lock!(gui_api_xvb).stats_priv.donor_1hr_avg * 1000.0; let runtime_mode = lock!(gui_api_xvb).stats_priv.runtime_mode.clone(); let runtime_donation_level = lock!(gui_api_xvb) @@ -171,7 +173,6 @@ impl<'a> Algorithm<'a> { / (new_instace.stats.hashrate_xmrig as u32)) * XVB_TIME_ALGO; - info!("XvB Process | Starting Algorithm - Algorithm State:",); info!("{:#?}", new_instace.stats); new_instace @@ -189,11 +190,6 @@ impl<'a> Algorithm<'a> { self.stats.xvb_1h_avg > self.stats.target_donation_hashrate } - async fn fulfill_xvb_1h(&self) { - self.mine_p2pool().await; - self.sleep_then_update_node_xmrig().await; - } - async fn mine_p2pool(&self) { if lock!(self.gui_api_xvb).current_node != Some(XvbNode::P2pool) { info!("Xvb Process | request xmrig to mine on p2pool"); @@ -398,11 +394,14 @@ impl<'a> Algorithm<'a> { ); output_console(self.gui_api_xvb, "Calculating donation time for XvB..."); - self.fulfill_xvb_1h().await + *lock!(self.time_donated) = self.stats.spared_time; + self.mine_p2pool().await; + self.sleep_then_update_node_xmrig().await; } else if self.is_share_fulfilled() { output_console(self.gui_api_xvb, "24H avg XvB target not achieved."); output_console(self.gui_api_xvb, "Sending all hashrate to XvB"); + *lock!(self.time_donated) = XVB_TIME_ALGO; self.mine_xvb().await } else { output_console(self.gui_api_xvb, "There are no shares in p2pool");