From 47e0b2ac74077b3e5ad1f4d2fe0978fa7408cd81 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 9 Dec 2013 16:11:31 +0100 Subject: [PATCH] [FIX] Network hashrate in dashboard Also adds some fixes for hashrate updates on the pool statistics page in case the API is disabled alltogether. Fixes #934 once merged. --- public/include/pages/statistics/pool.inc.php | 10 ++++++++++ public/include/smarty_globals.inc.php | 2 +- public/templates/mpos/statistics/pool/default.tpl | 2 ++ .../templates/mpos/statistics/pool/general_stats.tpl | 10 +++++----- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/public/include/pages/statistics/pool.inc.php b/public/include/pages/statistics/pool.inc.php index 91dca946..689d771d 100644 --- a/public/include/pages/statistics/pool.inc.php +++ b/public/include/pages/statistics/pool.inc.php @@ -41,6 +41,14 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { $dTimeSinceLast = 0; } + // Round progress + $iEstShares = $statistics->getEstimatedShares($dDifficulty); + if ($iEstShares > 0 && $aRoundShares['valid'] > 0) { + $dEstPercent = round(100 / $iEstShares * $aRoundShares['valid'], 2); + } else { + $dEstPercent = 0; + } + // Propagate content our template $smarty->assign("ESTTIME", $iEstTime); $smarty->assign("TIMESINCELAST", $dTimeSinceLast); @@ -50,6 +58,8 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { $smarty->assign("CONTRIBHASHES", $aContributorsHashes); $smarty->assign("CURRENTBLOCK", $iBlock); $smarty->assign("CURRENTBLOCKHASH", @$sBlockHash); + $smarty->assign('NETWORK', array('difficulty' => $dDifficulty, 'block' => $iBlock)); + $smarty->assign('ESTIMATES', array('shares' => $iEstShares, 'percent' => $dEstPercent)); if (count($aBlockData) > 0) { $smarty->assign("LASTBLOCK", $aBlockData['height']); $smarty->assign("LASTBLOCKHASH", $aBlockData['blockhash']); diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index a9424836..8cf2ba9e 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -35,7 +35,7 @@ if ( ! $dPersonalHashrateModifier = $setting->getValue('statistics_personal_hash if ( ! $dNetworkHashrateModifier = $setting->getValue('statistics_network_hashrate_modifier') ) $dNetworkHashrateModifier = 1; // Apply modifier now -$dNetworkHashrate = $dNetworkHashrate * $dNetworkHashrateModifier; +$dNetworkHashrate = $dNetworkHashrate / 1000 * $dNetworkHashrateModifier; $iCurrentPoolHashrate = $iCurrentPoolHashrate * $dPoolHashrateModifier; // Share rate of the entire pool diff --git a/public/templates/mpos/statistics/pool/default.tpl b/public/templates/mpos/statistics/pool/default.tpl index 4b3e5453..b47141d9 100644 --- a/public/templates/mpos/statistics/pool/default.tpl +++ b/public/templates/mpos/statistics/pool/default.tpl @@ -6,4 +6,6 @@ {include file="statistics/blocks/small_table.tpl" ALIGN="right" SHORT=true} +{if !$GLOBAL.website.api.disabled} {include file="statistics/js.tpl"} +{/if} diff --git a/public/templates/mpos/statistics/pool/general_stats.tpl b/public/templates/mpos/statistics/pool/general_stats.tpl index 0cad6b31..7b34ed84 100644 --- a/public/templates/mpos/statistics/pool/general_stats.tpl +++ b/public/templates/mpos/statistics/pool/general_stats.tpl @@ -5,7 +5,7 @@ Pool Hash Rate - {$GLOBAL.hashunits.pool} + {$GLOBAL.hashrate|number_format:"3"} {$GLOBAL.hashunits.pool} Pool Efficiency @@ -13,14 +13,14 @@ Current Active Workers - + {$GLOBAL.workers} Current Difficulty {if ! $GLOBAL.website.chaininfo.disabled} - + {$NETWORK.difficulty} {else} - + {$NETWORK.difficulty} {/if} @@ -29,7 +29,7 @@ Est. Shares this Round - + {$ESTIMATES.shares} (done: {$ESTIMATES.percent}%) {if ! $GLOBAL.website.blockexplorer.disabled}