Merge pull request #1047 from Fredyy90/patch-3

added blocks until next difficulty change to EstNextDifficulty
This commit is contained in:
Sebastian Grewe 2013-12-19 22:48:28 -08:00
commit 6d7004e5ec
8 changed files with 41 additions and 9 deletions

View File

@ -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

View File

@ -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
*

View File

@ -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);

View File

@ -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');
}

View File

@ -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']);

View File

@ -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 + "%)" );

View File

@ -7,7 +7,7 @@
</tr>
<tr>
<td><b>Est Next Difficulty</b></td>
<td id="b-nextdiff" class="right">{$NETWORK.EstNextDifficulty}</td>
<td id="b-nextdiff" class="right">{$NETWORK.EstNextDifficulty} (Change in {$NETWORK.BlocksUntilDiffChange} Blocks)</td>
</tr>
<tr>
<td><b>Est. Avg. Time per Block</b></td>

View File

@ -26,14 +26,14 @@
<tr>
<th align="left">Est. Next Difficulty</td>
{if ! $GLOBAL.website.chaininfo.disabled}
<td><a href="{$GLOBAL.website.chaininfo.url}" target="_new"><font size="2"><span id="b-diff">{$NETWORK.EstNextDifficulty}</span></font></a></td>
<td><a href="{$GLOBAL.website.chaininfo.url}" target="_new"><font size="2">{$NETWORK.EstNextDifficulty} (Change in {$NETWORK.BlocksUntilDiffChange} Blocks)</font></a></td>
{else}
<td><font size="2"><span id="b-diff">{$NETWORK.EstNextDifficulty}</span></font></td>
<td><font size="2">{$NETWORK.EstNextDifficulty} (Change in {$NETWORK.EstNextDifficulty} Blocks)</font></td>
{/if}
</tr>
<tr>
<th align="left">Est. Avg. Time per Round (Network)</td>
<td><font size="2"><span id="b-diff">{$NETWORK.EstTimePerBlock|seconds_to_words}</span></font></td>
<td><font size="2">{$NETWORK.EstTimePerBlock|seconds_to_words}</font></td>
</tr>
<tr>
<th align="left">Est. Avg. Time per Round (Pool)</td>