From f09459433b5274de77ebcc384544df1a83ce0752 Mon Sep 17 00:00:00 2001 From: Frederick Behrends Date: Mon, 16 Dec 2013 17:46:43 +0100 Subject: [PATCH] added "Est. Next Difficulty" and "Avg. Time per Round" to dashboard and dashboard api --- public/include/pages/api/getdashboarddata.inc.php | 5 ++++- public/include/pages/dashboard.inc.php | 5 ++++- public/include/pages/statistics/pool.inc.php | 6 +++--- public/templates/mpos/dashboard/js_api.tpl | 2 ++ public/templates/mpos/dashboard/network_info.tpl | 8 ++++++++ public/templates/mpos/statistics/pool/general_stats.tpl | 2 +- 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/public/include/pages/api/getdashboarddata.inc.php b/public/include/pages/api/getdashboarddata.inc.php index efc9d743..78f5206a 100644 --- a/public/include/pages/api/getdashboarddata.inc.php +++ b/public/include/pages/api/getdashboarddata.inc.php @@ -104,9 +104,12 @@ if ($iEstShares > 0 && $aRoundShares['valid'] > 0) { $dEstPercent = 0; } +$dExpectedTimePerBlock = pow(2, $config['target_bits']) * $dDifficulty / $dNetworkHashrate; +$dEstNextDifficulty = round($dDifficulty * $config['cointarget'] / $dExpectedTimePerBlock, 8); + // Output JSON format $data = array( - 'raw' => array( 'personal' => array( 'hashrate' => $dPersonalHashrate ), 'pool' => array( 'hashrate' => $dPoolHashrate ), 'network' => array( 'hashrate' => $dNetworkHashrate / 1000 ) ), + 'raw' => array( 'personal' => array( 'hashrate' => $dPersonalHashrate ), 'pool' => array( 'hashrate' => $dPoolHashrate ), 'network' => array( 'hashrate' => $dNetworkHashrate / 1000, 'esttimeperblock' => $dExpectedTimePerBlock, 'nextdifficulty' => $dEstNextDifficulty ) ), 'personal' => array ( 'hashrate' => $dPersonalHashrateAdjusted, 'sharerate' => $dPersonalSharerate, 'sharedifficulty' => $dPersonalShareDifficulty, 'shares' => array('valid' => $aUserRoundShares['valid'], 'invalid' => $aUserRoundShares['invalid'], 'invalid_percent' => $dUserInvalidPercent, 'unpaid' => $dUnpaidShares ), diff --git a/public/include/pages/dashboard.inc.php b/public/include/pages/dashboard.inc.php index 06b4f3b3..a5d1601b 100644 --- a/public/include/pages/dashboard.inc.php +++ b/public/include/pages/dashboard.inc.php @@ -35,11 +35,14 @@ if ($user->isAuthenticated()) { // Avoid confusion, ensure our nethash isn't higher than poolhash if ($iCurrentPoolHashrate > $dNetworkHashrate) $dNetworkHashrate = $iCurrentPoolHashrate; + $dExpectedTimePerBlock = pow(2, $config['target_bits']) * $dDifficulty / $dNetworkHashrate; + $dEstNextDifficulty = round($dDifficulty * $config['cointarget'] / $dExpectedTimePerBlock, 8); + // Make it available in Smarty $smarty->assign('DISABLED_DASHBOARD', $setting->getValue('disable_dashboard')); $smarty->assign('DISABLED_DASHBOARD_API', $setting->getValue('disable_dashboard_api')); $smarty->assign('ESTIMATES', array('shares' => $iEstShares, 'percent' => $dEstPercent)); - $smarty->assign('NETWORK', array('difficulty' => $dDifficulty, 'block' => $iBlock)); + $smarty->assign('NETWORK', array('difficulty' => $dDifficulty, 'block' => $iBlock, 'EstNextDifficulty' => $dEstNextDifficulty, 'EstTimePerBlock' => $dExpectedTimePerBlock)); $smarty->assign('INTERVAL', $interval / 60); $smarty->assign('CONTENT', 'default.tpl'); } diff --git a/public/include/pages/statistics/pool.inc.php b/public/include/pages/statistics/pool.inc.php index e5bd3bdf..3ebf2418 100644 --- a/public/include/pages/statistics/pool.inc.php +++ b/public/include/pages/statistics/pool.inc.php @@ -52,8 +52,8 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { $dEstPercent = 0; } - $dExpectedTimePerBlock = pow(2,32) * $dDifficulty / $dNetworkHashrate; - $dEstNextDifficulty = round($dDifficulty * 60 / $dExpectedTimePerBlock, 8); + $dExpectedTimePerBlock = pow(2, $config['target_bits']) * $dDifficulty / $dNetworkHashrate; + $dEstNextDifficulty = round($dDifficulty * $config['cointarget'] / $dExpectedTimePerBlock, 8); // Propagate content our template $smarty->assign("ESTTIME", $iEstTime); @@ -64,7 +64,7 @@ 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, 'EstNextDifficulty' => $dEstNextDifficulty, 'ExpectedTimePerBlock' => $dExpectedTimePerBlock)); + $smarty->assign('NETWORK', array('difficulty' => $dDifficulty, 'block' => $iBlock, 'EstNextDifficulty' => $dEstNextDifficulty, 'EstTimePerBlock' => $dExpectedTimePerBlock)); $smarty->assign('ESTIMATES', array('shares' => $iEstShares, 'percent' => $dEstPercent)); if (count($aBlockData) > 0) { $smarty->assign("LASTBLOCK", $aBlockData['height']); diff --git a/public/templates/mpos/dashboard/js_api.tpl b/public/templates/mpos/dashboard/js_api.tpl index 4a402675..f04bd9b5 100644 --- a/public/templates/mpos/dashboard/js_api.tpl +++ b/public/templates/mpos/dashboard/js_api.tpl @@ -140,6 +140,8 @@ $(document).ready(function(){ $('#b-pvalid').html(data.getdashboarddata.data.pool.shares.valid); $('#b-pivalid').html(data.getdashboarddata.data.pool.shares.invalid + " (" + data.getdashboarddata.data.pool.shares.invalid_percent + "%)" ); $('#b-diff').html(data.getdashboarddata.data.network.difficulty); + $('#b-nextdiff').html(data.getdashboarddata.data.network.nextdifficulty); + $('#b-esttimeperblock').html(data.getdashboarddata.data.network.esttimeperblock + " seconds"); // <- this needs some nicer format $('#b-nblock').html(data.getdashboarddata.data.network.block); $('#b-target').html(data.getdashboarddata.data.pool.shares.estimated + " (done: " + data.getdashboarddata.data.pool.shares.progress + "%)" ); {/literal}{if $GLOBAL.config.payout_system != 'pps'}{literal } diff --git a/public/templates/mpos/dashboard/network_info.tpl b/public/templates/mpos/dashboard/network_info.tpl index 1c8691c5..c470794b 100644 --- a/public/templates/mpos/dashboard/network_info.tpl +++ b/public/templates/mpos/dashboard/network_info.tpl @@ -5,6 +5,14 @@ Difficulty {$NETWORK.difficulty} + + Est Next Difficulty + {$NETWORK.EstNextDifficulty} + + + Est. Avg. Time per Block + {$NETWORK.EstTimePerBlock|seconds_to_words} + Current Block {$NETWORK.block} diff --git a/public/templates/mpos/statistics/pool/general_stats.tpl b/public/templates/mpos/statistics/pool/general_stats.tpl index f6e653c5..100d8b84 100644 --- a/public/templates/mpos/statistics/pool/general_stats.tpl +++ b/public/templates/mpos/statistics/pool/general_stats.tpl @@ -33,7 +33,7 @@ Est. Avg. Time per Round (Network) - {$NETWORK.ExpectedTimePerBlock|seconds_to_words} + {$NETWORK.EstTimePerBlock|seconds_to_words} Est. Avg. Time per Round (Pool)