From fca10e1a2c0d2ee8e6b3318f739f2e09090d0297 Mon Sep 17 00:00:00 2001 From: aglkm <39521015+aglkm@users.noreply.github.com> Date: Mon, 20 May 2024 19:02:12 +0300 Subject: [PATCH] Adjust hashrate metrics for testnet --- src/main.rs | 2 +- src/requests.rs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index c7227db..46159a8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -314,7 +314,7 @@ fn disk_usage(dashboard: &State>>) -> String { fn network_hashrate(dashboard: &State>>) -> String { let data = dashboard.lock().unwrap(); - format!("{} KG/s", data.hashrate) + data.hashrate.clone() } diff --git a/src/requests.rs b/src/requests.rs index 4fe3375..b885fa8 100644 --- a/src/requests.rs +++ b/src/requests.rs @@ -240,8 +240,16 @@ pub async fn get_mining_stats(dashboard: Arc>) -> Result<(), an // https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/52 // https://forum.grin.mw/t/difference-c31-and-c32-c33/7018/7 - let hashrate = (net_diff as f64) * 42.0 / 60.0 / 16384.0; - data.hashrate = format!("{:.2}", hashrate / 1000.0); + let hashrate = (net_diff as f64) * 42.0 / 60.0 / 16384.0; + + // KG/s + if hashrate > 1000.0 { + data.hashrate = format!("{:.2} KG/s", hashrate / 1000.0); + // G/s + } else { + data.hashrate = format!("{:.2} G/s", hashrate); + } + data.difficulty = net_diff.to_string(); if CONFIG.coingecko_api == "on" {