From 5f28567cc9fa2c205e6595fd7d5888ed1d6d51b2 Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 5 Feb 2023 22:02:03 -0500 Subject: [PATCH] Better estimated luck with less numerical error --- src/rpc.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/rpc.cpp b/src/rpc.cpp index 78f42cf..76a6857 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -928,12 +928,14 @@ void RPC::getInfoThenRefresh(bool force) { luck->display( QString("-") ); } else { // luck = current estimate of time to find a block given current localhash and nethash - double percentOfNetHash = localhashps.toDouble() / networkhashps.toInt(); + //TODO: maybe use this as a tooltip + double percentOfNetHash = localhashps.toDouble() / networkhashps.toDouble(); DEBUG( "% of nethash=" << percentOfNetHash ); - if (percentOfNetHash > 0) { + + if (localhashps.toDouble() > 0) { //TODO: this is only for DRAGONX int blocktime = 36; - double luckInSeconds = (1/percentOfNetHash)*blocktime; + double luckInSeconds = (networkhashps.toDouble()/localhashps.toDouble())*blocktime; double luckInHours = luckInSeconds / (60*60); luck->display( QString::number( luckInHours , 'f', 2 ) ); }