diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index 463c07fa..f3398284 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -759,7 +759,7 @@ class Statistics { SELECT IFNULL(COUNT(id), 0) as count, IFNULL(AVG(difficulty), 0) as average, - IFNULL(ROUND(SUM((difficulty * 65536) / POW(2, (" . $this->config['difficulty'] . " -16))), 0), 0) AS expected, + IFNULL(ROUND(SUM((POW(2, ( 32 - " . $this->config['target_bits'] . " )) * difficulty) / POW(2, (" . $this->config['difficulty'] . " -16))), 0), 0) AS expected, IFNULL(ROUND(SUM(shares)), 0) as shares, IFNULL(SUM(amount), 0) as rewards FROM " . $this->block->getTableName() . " @@ -772,6 +772,14 @@ class Statistics { return false; } + /** + * Caclulate estimated shares based on network difficulty and pool difficulty + * @param dDiff double Network difficulty + * @return shares integer Share count + **/ + public function getEstimatedShares($dDiff) { + return round((POW(2, (32 - $this->config['target_bits'])) * $dDiff) / pow(2, ($this->config['difficulty'] - 16))); + } } diff --git a/public/include/pages/api/getdashboarddata.inc.php b/public/include/pages/api/getdashboarddata.inc.php index 7942092c..35f5eb49 100644 --- a/public/include/pages/api/getdashboarddata.inc.php +++ b/public/include/pages/api/getdashboarddata.inc.php @@ -80,7 +80,7 @@ $aWorkers = $worker->getWorkers($user_id, $interval); $aPrice = $setting->getValue('price'); // Round progress -$iEstShares = round((65536 * $dDifficulty) / pow(2, ($config['difficulty'] - 16))); +$iEstShares = $statistics->getEstimatedShares($dDifficulty); $dEstPercent = round(100 / $iEstShares * $aRoundShares['valid'], 2); // Output JSON format diff --git a/public/include/pages/api/getnavbardata.inc.php b/public/include/pages/api/getnavbardata.inc.php index 38041737..345dba0d 100644 --- a/public/include/pages/api/getnavbardata.inc.php +++ b/public/include/pages/api/getnavbardata.inc.php @@ -44,7 +44,7 @@ if ($iTotalRoundShares > 0) { } // Round progress -$iEstShares = round((65536 * $dDifficulty) / pow(2, ($config['difficulty'] - 16))); +$iEstShares = $statistics->getEstimatedShares($dDifficulty); $dEstPercent = round(100 / $iEstShares * $aRoundShares['valid'], 2); // Output JSON format diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index 630cbed6..42406331 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -65,6 +65,7 @@ $aGlobal = array( 'price' => $setting->getValue('price'), 'disable_mp' => $setting->getValue('disable_mp'), 'config' => array( + 'target_bits' => $config['target_bits'], 'accounts' => $config['accounts'], 'disable_invitations' => $setting->getValue('disable_invitations'), 'disable_notifications' => $setting->getValue('disable_notifications'), diff --git a/public/templates/mmcFE/statistics/blocks/default.tpl b/public/templates/mmcFE/statistics/blocks/default.tpl index 5e80d361..28fdd3d6 100644 --- a/public/templates/mmcFE/statistics/blocks/default.tpl +++ b/public/templates/mmcFE/statistics/blocks/default.tpl @@ -131,7 +131,7 @@ target and network difficulty and assuming a zero variance scenario. {$BLOCKSFOUND[block].shares|number_format} {math assign="percentage" equation="shares / estshares * 100" shares=$BLOCKSFOUND[block].shares estshares=$BLOCKSFOUND[block].estshares} - {assign var="totalpercentage" value=$totalpercentage+$percentage} + {assign var="totalpercentage" value=$totalpercentage+$percentage} {$percentage|number_format:"2"} diff --git a/public/templates/mmcFE/statistics/pool/default.tpl b/public/templates/mmcFE/statistics/pool/default.tpl index 9b2f86b3..7cf67f68 100644 --- a/public/templates/mmcFE/statistics/pool/default.tpl +++ b/public/templates/mmcFE/statistics/pool/default.tpl @@ -48,7 +48,7 @@ Est. Shares this Round - {assign var=estshares value=(65536 * $DIFFICULTY) / pow(2, ($GLOBAL.config.targetdiff - 16))} + {assign var=estshares value=(pow(2, (32 - $GLOBAL.config.target_bits)) * $DIFFICULTY) / pow(2, ($GLOBAL.config.targetdiff - 16))} {$estshares|number_format:"0"} (done: {(100 / $estshares * $GLOBAL.roundshares.valid)|number_format:"2"} %) diff --git a/public/templates/mpos/statistics/blocks/default.tpl b/public/templates/mpos/statistics/blocks/default.tpl index 0eae6232..4b9529ef 100644 --- a/public/templates/mpos/statistics/blocks/default.tpl +++ b/public/templates/mpos/statistics/blocks/default.tpl @@ -13,7 +13,7 @@ Expected {section block $BLOCKSFOUND step=-1} - {round(pow(2,32 - $GLOBAL.config.targetdiff) * $BLOCKSFOUND[block].difficulty)} + {$BLOCKSFOUND[block].estshares} {/section}