diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index 29b97ca6..2399326f 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -835,6 +835,22 @@ class Statistics extends Base { return $this->memcache->setCache(__FUNCTION__, round($dDifficulty * $this->config['cointarget'] / $this->getNetworkExpectedTimePerBlock(), 8)); } + /** + * Get Number of blocks until next difficulty change + * @return blocks int blocks until difficulty change + **/ + public function getBlocksUntilDiffChange(){ + if ($data = $this->memcache->get(__FUNCTION__)) return $data; + + if ($this->bitcoin->can_connect() === true) { + $iBlockcount = $this->bitcoin->getblockcount(); + } else { + $iBlockcount = 1; + } + + return $this->memcache->setCache(__FUNCTION__, $this->config['coindiffchangetarget'] - ($iBlockcount % $this->config['coindiffchangetarget'])); + } + /** * Get current PPS value * @return value double PPS Value diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php index 780ec62d..8d59ba48 100644 --- a/public/include/config/global.inc.dist.php +++ b/public/include/config/global.inc.dist.php @@ -178,6 +178,19 @@ $config['currency'] = 'LTC'; **/ $config['cointarget'] = '150'; +/** + * Diff change every X Blocks + * + * Explanation + * Amount of Blocks until Difficulty change + * + * Fastcoin: 300 Blocks + * Litecoin: 2016 Blocks + * Bitcoin: 2016 Blocks + * + **/ +$config['coindiffchangetarget'] = 2016; + /** * Default transaction fee to apply to user transactions * diff --git a/public/include/pages/api/getdashboarddata.inc.php b/public/include/pages/api/getdashboarddata.inc.php index ee5cdc70..f36a210e 100644 --- a/public/include/pages/api/getdashboarddata.inc.php +++ b/public/include/pages/api/getdashboarddata.inc.php @@ -91,10 +91,11 @@ if ($iEstShares > 0 && $aRoundShares['valid'] > 0) { $dExpectedTimePerBlock = $statistics->getNetworkExpectedTimePerBlock(); $dEstNextDifficulty = $statistics->getExpectedNextDifficulty(); +$iBlocksUntilDiffChange = $statistics->getBlocksUntilDiffChange(); // Output JSON format $data = array( - 'raw' => array( 'personal' => array( 'hashrate' => $dPersonalHashrate ), 'pool' => array( 'hashrate' => $dPoolHashrate ), 'network' => array( 'hashrate' => $dNetworkHashrate / 1000, 'esttimeperblock' => $dExpectedTimePerBlock, 'nextdifficulty' => $dEstNextDifficulty ) ), + 'raw' => array( 'personal' => array( 'hashrate' => $dPersonalHashrate ), 'pool' => array( 'hashrate' => $dPoolHashrate ), 'network' => array( 'hashrate' => $dNetworkHashrate / 1000, 'esttimeperblock' => $dExpectedTimePerBlock, 'nextdifficulty' => $dEstNextDifficulty, 'blocksuntildiffchange' => $iBlocksUntilDiffChange ) ), 'personal' => array ( 'hashrate' => $dPersonalHashrateAdjusted, 'sharerate' => $dPersonalSharerate, 'sharedifficulty' => $dPersonalShareDifficulty, 'shares' => array('valid' => $aUserRoundShares['valid'], 'invalid' => $aUserRoundShares['invalid'], 'invalid_percent' => $dUserInvalidPercent, 'unpaid' => $dUnpaidShares ), @@ -111,7 +112,7 @@ $data = array( 'target_bits' => $config['difficulty'] ), 'system' => array( 'load' => sys_getloadavg() ), - 'network' => array( 'hashrate' => $dNetworkHashrateAdjusted, 'difficulty' => $dDifficulty, 'block' => $iBlock, 'esttimeperblock' => round($dExpectedTimePerBlock ,2), 'nextdifficulty' => $dEstNextDifficulty ), + 'network' => array( 'hashrate' => $dNetworkHashrateAdjusted, 'difficulty' => $dDifficulty, 'block' => $iBlock, 'esttimeperblock' => round($dExpectedTimePerBlock ,2), 'nextdifficulty' => $dEstNextDifficulty, 'blocksuntildiffchange' => $iBlocksUntilDiffChange ), ); echo $api->get_json($data); diff --git a/public/include/pages/dashboard.inc.php b/public/include/pages/dashboard.inc.php index 86ccc331..f835f6e7 100644 --- a/public/include/pages/dashboard.inc.php +++ b/public/include/pages/dashboard.inc.php @@ -37,12 +37,13 @@ if ($user->isAuthenticated()) { $dExpectedTimePerBlock = $statistics->getNetworkExpectedTimePerBlock(); $dEstNextDifficulty = $statistics->getExpectedNextDifficulty(); + $iBlocksUntilDiffChange = $statistics->getBlocksUntilDiffChange(); // 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, 'EstNextDifficulty' => $dEstNextDifficulty, 'EstTimePerBlock' => $dExpectedTimePerBlock)); + $smarty->assign('NETWORK', array('difficulty' => $dDifficulty, 'block' => $iBlock, 'EstNextDifficulty' => $dEstNextDifficulty, 'EstTimePerBlock' => $dExpectedTimePerBlock, 'BlocksUntilDiffChange' => $iBlocksUntilDiffChange)); $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 1e3f65f3..5dd26d29 100644 --- a/public/include/pages/statistics/pool.inc.php +++ b/public/include/pages/statistics/pool.inc.php @@ -54,6 +54,7 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { $dExpectedTimePerBlock = $statistics->getNetworkExpectedTimePerBlock(); $dEstNextDifficulty = $statistics->getExpectedNextDifficulty(); + $iBlocksUntilDiffChange = $statistics->getBlocksUntilDiffChange(); // Propagate content our template $smarty->assign("ESTTIME", $iEstTime); @@ -64,7 +65,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, 'EstTimePerBlock' => $dExpectedTimePerBlock)); + $smarty->assign('NETWORK', array('difficulty' => $dDifficulty, 'block' => $iBlock, 'EstNextDifficulty' => $dEstNextDifficulty, 'EstTimePerBlock' => $dExpectedTimePerBlock, 'BlocksUntilDiffChange' => $iBlocksUntilDiffChange)); $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 b78b5bc4..dc3508dc 100644 --- a/public/templates/mpos/dashboard/js_api.tpl +++ b/public/templates/mpos/dashboard/js_api.tpl @@ -140,7 +140,7 @@ $(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-nextdiff').html(data.getdashboarddata.data.network.nextdifficulty + " (Change in " + data.getdashboarddata.data.network.blocksuntildiffchange + " Blocks)"); $('#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 + "%)" ); diff --git a/public/templates/mpos/dashboard/network_info.tpl b/public/templates/mpos/dashboard/network_info.tpl index c470794b..d8c7642b 100644 --- a/public/templates/mpos/dashboard/network_info.tpl +++ b/public/templates/mpos/dashboard/network_info.tpl @@ -7,7 +7,7 @@