Merge pull request #2191 from MPOS/estblock-changes
[CHANGE] Est time per block changes
This commit is contained in:
commit
5724068140
@ -815,21 +815,23 @@ class Statistics extends Base {
|
|||||||
* Get the Expected Time per Block in the whole Network in seconde
|
* Get the Expected Time per Block in the whole Network in seconde
|
||||||
* @return seconds double Seconds per Block
|
* @return seconds double Seconds per Block
|
||||||
*/
|
*/
|
||||||
public function getNetworkExpectedTimePerBlock(){
|
public function getExpectedTimePerBlock($type='network',$hashrate = 0){
|
||||||
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
|
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
|
||||||
|
|
||||||
if ($this->bitcoin->can_connect() === true) {
|
if ($this->bitcoin->can_connect() === true) {
|
||||||
$dNetworkHashrate = $this->bitcoin->getnetworkhashps();
|
if ($type == 'network') {
|
||||||
|
$hashrate = $this->bitcoin->getnetworkhashps();
|
||||||
|
} else {
|
||||||
|
// We need hashes/second and expect khash as input
|
||||||
|
$hashrate = $hashrate * 1000;
|
||||||
|
}
|
||||||
$dDifficulty = $this->bitcoin->getdifficulty();
|
$dDifficulty = $this->bitcoin->getdifficulty();
|
||||||
} else {
|
} else {
|
||||||
$dNetworkHashrate = 1;
|
$hashrate = 1;
|
||||||
$dDifficulty = 1;
|
$dDifficulty = 1;
|
||||||
}
|
}
|
||||||
if($dNetworkHashrate <= 0){
|
if ($hashrate <= 0) $hashrate = 1;
|
||||||
return $this->memcache->setCache(__FUNCTION__, $this->config['cointarget']);
|
return $this->memcache->setCache(__FUNCTION__, $this->coin->calcNetworkExpectedTimePerBlock($dDifficulty, $hashrate));
|
||||||
}
|
|
||||||
|
|
||||||
return $this->memcache->setCache(__FUNCTION__, $this->coin->calcNetworkExpectedTimePerBlock($dDifficulty, $dNetworkHashrate));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -78,7 +78,8 @@ $iEstShares = $statistics->getEstimatedShares($dDifficulty);
|
|||||||
$iEstShares > 0 && $aRoundShares['valid'] > 0 ? $dEstPercent = round(100 / $iEstShares * $aRoundShares['valid'], 2) : $dEstPercent = 0;
|
$iEstShares > 0 && $aRoundShares['valid'] > 0 ? $dEstPercent = round(100 / $iEstShares * $aRoundShares['valid'], 2) : $dEstPercent = 0;
|
||||||
|
|
||||||
// Some estimates
|
// Some estimates
|
||||||
$dExpectedTimePerBlock = $statistics->getNetworkExpectedTimePerBlock();
|
$dExpectedTimePerBlock = $statistics->getExpectedTimePerBlock();
|
||||||
|
$dPoolExpectedTimePerBlock = $statistics->getExpectedTimePerBlock('pool', $dPoolHashrate);
|
||||||
$dEstNextDifficulty = $statistics->getExpectedNextDifficulty();
|
$dEstNextDifficulty = $statistics->getExpectedNextDifficulty();
|
||||||
$iBlocksUntilDiffChange = $statistics->getBlocksUntilDiffChange();
|
$iBlocksUntilDiffChange = $statistics->getBlocksUntilDiffChange();
|
||||||
|
|
||||||
@ -105,6 +106,7 @@ $data = array(
|
|||||||
'name' => $setting->getValue('website_name'),
|
'name' => $setting->getValue('website_name'),
|
||||||
'currency' => $config['currency']
|
'currency' => $config['currency']
|
||||||
),
|
),
|
||||||
|
'esttimeperblock' => round($dPoolExpectedTimePerBlock, 2),
|
||||||
'blocks' => $aLastBlocks,
|
'blocks' => $aLastBlocks,
|
||||||
'workers' => $worker->getCountAllActiveWorkers(), 'hashrate' => $dPoolHashrateAdjusted,
|
'workers' => $worker->getCountAllActiveWorkers(), 'hashrate' => $dPoolHashrateAdjusted,
|
||||||
'shares' => array( 'valid' => $aRoundShares['valid'], 'invalid' => $aRoundShares['invalid'], 'invalid_percent' => $dPoolInvalidPercent, 'estimated' => $iEstShares, 'progress' => $dEstPercent ),
|
'shares' => array( 'valid' => $aRoundShares['valid'], 'invalid' => $aRoundShares['invalid'], 'invalid_percent' => $dPoolInvalidPercent, 'estimated' => $iEstShares, 'progress' => $dEstPercent ),
|
||||||
|
|||||||
@ -33,7 +33,7 @@ if ($user->isAuthenticated()) {
|
|||||||
// Avoid confusion, ensure our nethash isn't higher than poolhash
|
// Avoid confusion, ensure our nethash isn't higher than poolhash
|
||||||
if ($iCurrentPoolHashrate > $dNetworkHashrate) $dNetworkHashrate = $iCurrentPoolHashrate;
|
if ($iCurrentPoolHashrate > $dNetworkHashrate) $dNetworkHashrate = $iCurrentPoolHashrate;
|
||||||
|
|
||||||
$dExpectedTimePerBlock = $statistics->getNetworkExpectedTimePerBlock();
|
$dExpectedTimePerBlock = $statistics->getExpectedTimePerBlock('pool', $iCurrentPoolHashrate);
|
||||||
$dEstNextDifficulty = $statistics->getExpectedNextDifficulty();
|
$dEstNextDifficulty = $statistics->getExpectedNextDifficulty();
|
||||||
$iBlocksUntilDiffChange = $statistics->getBlocksUntilDiffChange();
|
$iBlocksUntilDiffChange = $statistics->getBlocksUntilDiffChange();
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,7 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) {
|
|||||||
$iCurrentPoolHashrate = $statistics->getCurrentHashrate();
|
$iCurrentPoolHashrate = $statistics->getCurrentHashrate();
|
||||||
|
|
||||||
// Time in seconds, not hours, using modifier in smarty to translate
|
// Time in seconds, not hours, using modifier in smarty to translate
|
||||||
$iCurrentPoolHashrate > 0 ? $iEstTime = $dDifficulty * pow(2,32) / ($iCurrentPoolHashrate * 1000) : $iEstTime = 0;
|
$iCurrentPoolHashrate > 0 ? $iEstTime = $statistics->getExpectedTimePerBlock('pool', $iCurrentPoolHashrate) : $iEstTime = 0;
|
||||||
|
|
||||||
// Time since last block
|
// Time since last block
|
||||||
if (!empty($aBlockData)) {
|
if (!empty($aBlockData)) {
|
||||||
@ -54,7 +54,7 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) {
|
|||||||
$dEstPercent = 0;
|
$dEstPercent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dExpectedTimePerBlock = $statistics->getNetworkExpectedTimePerBlock();
|
$dExpectedTimePerBlock = $statistics->getExpectedTimePerBlock();
|
||||||
$dEstNextDifficulty = $statistics->getExpectedNextDifficulty();
|
$dEstNextDifficulty = $statistics->getExpectedNextDifficulty();
|
||||||
$iBlocksUntilDiffChange = $statistics->getBlocksUntilDiffChange();
|
$iBlocksUntilDiffChange = $statistics->getBlocksUntilDiffChange();
|
||||||
|
|
||||||
|
|||||||
@ -117,8 +117,8 @@ $(document).ready(function(){
|
|||||||
$('#b-nextdiff').html('n/a');
|
$('#b-nextdiff').html('n/a');
|
||||||
$('#b-nextdiffc').html(' No Estimates');
|
$('#b-nextdiffc').html(' No Estimates');
|
||||||
}
|
}
|
||||||
var minutes = Math.floor(data.getdashboarddata.data.network.esttimeperblock / 60);
|
var minutes = Math.floor(data.getdashboarddata.data.pool.esttimeperblock / 60);
|
||||||
var seconds = Math.floor(data.getdashboarddata.data.network.esttimeperblock - minutes * 60);
|
var seconds = Math.floor(data.getdashboarddata.data.pool.esttimeperblock - minutes * 60);
|
||||||
$('#b-esttimeperblock').html(minutes + " minutes " + seconds + " seconds"); // <- this needs some nicer format
|
$('#b-esttimeperblock').html(minutes + " minutes " + seconds + " seconds"); // <- this needs some nicer format
|
||||||
$('#b-nblock').html(data.getdashboarddata.data.network.block);
|
$('#b-nblock').html(data.getdashboarddata.data.network.block);
|
||||||
$('#b-roundprogress').html(number_format(parseFloat(data.getdashboarddata.data.pool.shares.progress).toFixed(2), 2) + "%");
|
$('#b-roundprogress').html(number_format(parseFloat(data.getdashboarddata.data.pool.shares.progress).toFixed(2), 2) + "%");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user