From c856e48133dcf977577a8a66641931dd701a8c9c Mon Sep 17 00:00:00 2001 From: stringhandler Date: Tue, 27 Aug 2024 21:02:24 +0200 Subject: [PATCH] scan more blocks --- src-tauri/src/node_adapter.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src-tauri/src/node_adapter.rs b/src-tauri/src/node_adapter.rs index fd77834e8..f6cec88c6 100644 --- a/src-tauri/src/node_adapter.rs +++ b/src-tauri/src/node_adapter.rs @@ -180,16 +180,20 @@ impl MinotariNodeStatusMonitor { res.metadata.as_ref().unwrap().best_block_hash.clone(), res.metadata.unwrap().timestamp, ); + // Unfortunately have to use 100 blocks to ensure that there are both randomx and sha blocks included + // otherwise the hashrate is 0 for one of them. let res = client .get_network_difficulty(HeightRequest { - from_tip: 1, + from_tip: 100, start_height: 0, end_height: 0, }) .await?; let mut res = res.into_inner(); + // Get the last one. + let mut result = Err(anyhow::anyhow!("No difficulty found")); if let Some(difficulty) = res.message().await? { - return Ok(( + result = Ok(( difficulty.sha3x_estimated_hash_rate, difficulty.randomx_estimated_hash_rate, MicroMinotari(reward), @@ -198,8 +202,8 @@ impl MinotariNodeStatusMonitor { sync_achieved, )); } - // Really unlikely to arrive here - Err(anyhow::anyhow!("No difficulty found")) + + result } pub async fn get_identity(&self) -> Result {