Merge pull request #1047 from Fredyy90/patch-3
added blocks until next difficulty change to EstNextDifficulty
This commit is contained in:
commit
6d7004e5ec
@ -835,6 +835,22 @@ class Statistics extends Base {
|
|||||||
return $this->memcache->setCache(__FUNCTION__, round($dDifficulty * $this->config['cointarget'] / $this->getNetworkExpectedTimePerBlock(), 8));
|
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
|
* Get current PPS value
|
||||||
* @return value double PPS Value
|
* @return value double PPS Value
|
||||||
|
|||||||
@ -178,6 +178,19 @@ $config['currency'] = 'LTC';
|
|||||||
**/
|
**/
|
||||||
$config['cointarget'] = '150';
|
$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
|
* Default transaction fee to apply to user transactions
|
||||||
*
|
*
|
||||||
|
|||||||
@ -91,10 +91,11 @@ if ($iEstShares > 0 && $aRoundShares['valid'] > 0) {
|
|||||||
|
|
||||||
$dExpectedTimePerBlock = $statistics->getNetworkExpectedTimePerBlock();
|
$dExpectedTimePerBlock = $statistics->getNetworkExpectedTimePerBlock();
|
||||||
$dEstNextDifficulty = $statistics->getExpectedNextDifficulty();
|
$dEstNextDifficulty = $statistics->getExpectedNextDifficulty();
|
||||||
|
$iBlocksUntilDiffChange = $statistics->getBlocksUntilDiffChange();
|
||||||
|
|
||||||
// Output JSON format
|
// Output JSON format
|
||||||
$data = array(
|
$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 (
|
'personal' => array (
|
||||||
'hashrate' => $dPersonalHashrateAdjusted, 'sharerate' => $dPersonalSharerate, 'sharedifficulty' => $dPersonalShareDifficulty,
|
'hashrate' => $dPersonalHashrateAdjusted, 'sharerate' => $dPersonalSharerate, 'sharedifficulty' => $dPersonalShareDifficulty,
|
||||||
'shares' => array('valid' => $aUserRoundShares['valid'], 'invalid' => $aUserRoundShares['invalid'], 'invalid_percent' => $dUserInvalidPercent, 'unpaid' => $dUnpaidShares ),
|
'shares' => array('valid' => $aUserRoundShares['valid'], 'invalid' => $aUserRoundShares['invalid'], 'invalid_percent' => $dUserInvalidPercent, 'unpaid' => $dUnpaidShares ),
|
||||||
@ -111,7 +112,7 @@ $data = array(
|
|||||||
'target_bits' => $config['difficulty']
|
'target_bits' => $config['difficulty']
|
||||||
),
|
),
|
||||||
'system' => array( 'load' => sys_getloadavg() ),
|
'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);
|
echo $api->get_json($data);
|
||||||
|
|||||||
@ -37,12 +37,13 @@ if ($user->isAuthenticated()) {
|
|||||||
|
|
||||||
$dExpectedTimePerBlock = $statistics->getNetworkExpectedTimePerBlock();
|
$dExpectedTimePerBlock = $statistics->getNetworkExpectedTimePerBlock();
|
||||||
$dEstNextDifficulty = $statistics->getExpectedNextDifficulty();
|
$dEstNextDifficulty = $statistics->getExpectedNextDifficulty();
|
||||||
|
$iBlocksUntilDiffChange = $statistics->getBlocksUntilDiffChange();
|
||||||
|
|
||||||
// Make it available in Smarty
|
// Make it available in Smarty
|
||||||
$smarty->assign('DISABLED_DASHBOARD', $setting->getValue('disable_dashboard'));
|
$smarty->assign('DISABLED_DASHBOARD', $setting->getValue('disable_dashboard'));
|
||||||
$smarty->assign('DISABLED_DASHBOARD_API', $setting->getValue('disable_dashboard_api'));
|
$smarty->assign('DISABLED_DASHBOARD_API', $setting->getValue('disable_dashboard_api'));
|
||||||
$smarty->assign('ESTIMATES', array('shares' => $iEstShares, 'percent' => $dEstPercent));
|
$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('INTERVAL', $interval / 60);
|
||||||
$smarty->assign('CONTENT', 'default.tpl');
|
$smarty->assign('CONTENT', 'default.tpl');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,6 +54,7 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) {
|
|||||||
|
|
||||||
$dExpectedTimePerBlock = $statistics->getNetworkExpectedTimePerBlock();
|
$dExpectedTimePerBlock = $statistics->getNetworkExpectedTimePerBlock();
|
||||||
$dEstNextDifficulty = $statistics->getExpectedNextDifficulty();
|
$dEstNextDifficulty = $statistics->getExpectedNextDifficulty();
|
||||||
|
$iBlocksUntilDiffChange = $statistics->getBlocksUntilDiffChange();
|
||||||
|
|
||||||
// Propagate content our template
|
// Propagate content our template
|
||||||
$smarty->assign("ESTTIME", $iEstTime);
|
$smarty->assign("ESTTIME", $iEstTime);
|
||||||
@ -64,7 +65,7 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) {
|
|||||||
$smarty->assign("CONTRIBHASHES", $aContributorsHashes);
|
$smarty->assign("CONTRIBHASHES", $aContributorsHashes);
|
||||||
$smarty->assign("CURRENTBLOCK", $iBlock);
|
$smarty->assign("CURRENTBLOCK", $iBlock);
|
||||||
$smarty->assign("CURRENTBLOCKHASH", @$sBlockHash);
|
$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));
|
$smarty->assign('ESTIMATES', array('shares' => $iEstShares, 'percent' => $dEstPercent));
|
||||||
if (count($aBlockData) > 0) {
|
if (count($aBlockData) > 0) {
|
||||||
$smarty->assign("LASTBLOCK", $aBlockData['height']);
|
$smarty->assign("LASTBLOCK", $aBlockData['height']);
|
||||||
|
|||||||
@ -140,7 +140,7 @@ $(document).ready(function(){
|
|||||||
$('#b-pvalid').html(data.getdashboarddata.data.pool.shares.valid);
|
$('#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-pivalid').html(data.getdashboarddata.data.pool.shares.invalid + " (" + data.getdashboarddata.data.pool.shares.invalid_percent + "%)" );
|
||||||
$('#b-diff').html(data.getdashboarddata.data.network.difficulty);
|
$('#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-esttimeperblock').html(data.getdashboarddata.data.network.esttimeperblock + " seconds"); // <- this needs some nicer format
|
||||||
$('#b-nblock').html(data.getdashboarddata.data.network.block);
|
$('#b-nblock').html(data.getdashboarddata.data.network.block);
|
||||||
$('#b-target').html(data.getdashboarddata.data.pool.shares.estimated + " (done: " + data.getdashboarddata.data.pool.shares.progress + "%)" );
|
$('#b-target').html(data.getdashboarddata.data.pool.shares.estimated + " (done: " + data.getdashboarddata.data.pool.shares.progress + "%)" );
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><b>Est Next Difficulty</b></td>
|
<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>
|
||||||
<tr>
|
<tr>
|
||||||
<td><b>Est. Avg. Time per Block</b></td>
|
<td><b>Est. Avg. Time per Block</b></td>
|
||||||
|
|||||||
@ -26,14 +26,14 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th align="left">Est. Next Difficulty</td>
|
<th align="left">Est. Next Difficulty</td>
|
||||||
{if ! $GLOBAL.website.chaininfo.disabled}
|
{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}
|
{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}
|
{/if}
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th align="left">Est. Avg. Time per Round (Network)</td>
|
<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>
|
||||||
<tr>
|
<tr>
|
||||||
<th align="left">Est. Avg. Time per Round (Pool)</td>
|
<th align="left">Est. Avg. Time per Round (Pool)</td>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user