From f35c7cedc812f6991221fa5c2add75080ad5f0ab Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 13 Sep 2013 10:28:12 +0200 Subject: [PATCH] adding network hashrate to poolstatus --- public/include/pages/api/getpoolstatus.inc.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/public/include/pages/api/getpoolstatus.inc.php b/public/include/pages/api/getpoolstatus.inc.php index 4cf0d5ef..662f80fb 100644 --- a/public/include/pages/api/getpoolstatus.inc.php +++ b/public/include/pages/api/getpoolstatus.inc.php @@ -22,14 +22,19 @@ if ($bitcoin->can_connect() === true){ if (is_array($dDifficulty) && array_key_exists('proof-of-work', $dDifficulty)) $dDifficulty = $dDifficulty['proof-of-work']; $iBlock = $bitcoin->getblockcount(); + $dNetworkHashrate = $bitcoin->query('getnetworkhashps'); } else { $dDifficulty = 1; $iBlock = 0; + $dNetworkHashrate = 0; } // Estimated time to find the next block $iCurrentPoolHashrate = $statistics->getCurrentHashrate(); +// Avoid confusion, ensure our nethash isn't higher than poolhash +if ($iCurrentPoolHashrate > $dNetworkHashrate) $dNetworkHashrate = $iCurrentPoolHashrate; + // Time in seconds, not hours, using modifier in smarty to translate $iCurrentPoolHashrate > 0 ? $iEstTime = $dDifficulty * pow(2,32) / ($iCurrentPoolHashrate * 1000) : $iEstTime = 0; $iEstShares = (pow(2, 32 - $config['difficulty']) * $dDifficulty); @@ -56,6 +61,7 @@ echo json_encode( 'esttime' => $iEstTime, 'estshares' => $iEstShares, 'timesincelast' => $dTimeSinceLast, + 'nethashrate' => $dNetworkHashrate ))); // Supress master template