diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index 558c3e85..434d3074 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -47,6 +47,7 @@ if ( $bitcoin->can_connect() === true ){ // We support some dynamic reward targets but fall back to our fixed value // Re-calculate after each run due to re-targets in this loop +// We don't use the classes implementation just in case people start mucking around with it if ($config['pps']['reward']['type'] == 'blockavg' && $block->getBlockCount() > 0) { $pps_reward = round($block->getAvgBlockReward($config['pps']['blockavg']['blockcount'])); $log->logInfo("PPS reward using block average, amount: " . $pps_reward . "\tdifficulty: " . $dDifficulty); @@ -65,7 +66,6 @@ if ($config['pps']['reward']['type'] == 'blockavg' && $block->getBlockCount() > // Per-share value to be paid out to users $pps_value = round($pps_reward / (pow(2, $config['target_bits']) * $dDifficulty), 12); - // Find our last share accounted and last inserted share for PPS calculations $iPreviousShareId = $setting->getValue('pps_last_share_id'); $iLastShareId = $share->getLastInsertedShareId(); diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index 01982c2a..601b5863 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -822,7 +822,7 @@ class Statistics extends Base { /** * Get the Expected next Difficulty * @return difficulty double Next difficulty - */ + **/ public function getExpectedNextDifficulty(){ if ($data = $this->memcache->get(__FUNCTION__)) return $data; @@ -835,6 +835,34 @@ class Statistics extends Base { return round($dDifficulty * $this->config['cointarget'] / $this->getNetworkExpectedTimePerBlock(), 8); } + /** + * Get current PPS value + * @return value double PPS Value + **/ + + public function getPPSValue() { + // Fetch RPC difficulty + if ($this->bitcoin->can_connect() === true) { + $dDifficulty = $this->bitcoin->getdifficulty(); + } else { + $dDifficulty = 1; + } + + if ($this->config['pps']['reward']['type'] == 'blockavg' && $this->block->getBlockCount() > 0) { + $pps_reward = round($this->block->getAvgBlockReward($this->config['pps']['blockavg']['blockcount'])); + } else { + if ($this->config['pps']['reward']['type'] == 'block') { + if ($aLastBlock = $this->block->getLast()) { + $pps_reward = $aLastBlock['amount']; + } else { + $pps_reward = $this->config['pps']['reward']['default']; + } + } else { + $pps_reward = $this->config['pps']['reward']['default']; + } + } + return round($pps_reward / (pow(2, $this->config['target_bits']) * $dDifficulty), 12); + } } $statistics = new Statistics(); diff --git a/public/include/pages/admin/user.inc.php b/public/include/pages/admin/user.inc.php index c7c7470a..e6fcacaa 100644 --- a/public/include/pages/admin/user.inc.php +++ b/public/include/pages/admin/user.inc.php @@ -40,7 +40,14 @@ if (@$_POST['query']) { $aBalance = $transaction->getBalance($aUser['id']); $aUser['balance'] = $aBalance['confirmed']; $aUser['hashrate'] = $statistics->getUserHashrate($aUser['id']); - $aUser['estimates'] = $statistics->getUserEstimates($aRoundShares, $aUser['shares'], $aUser['donate_percent'], $aUser['no_fees']); + + if ($config['payout_system'] == 'pps') { + $aUser['sharerate'] = $statistics->getUserSharerate($aUser['id']); + $aUser['difficulty'] = $statistics->getUserShareDifficulty($aUser['id']); + $aUser['estimates'] = $statistics->getUserEstimates($aUser['sharerate'], $aUser['difficulty'], $user->getUserDonatePercent($aUser['id']), $user->getUserNoFee($aUser['id']), $statistics->getPPSValue()); + } else { + $aUser['estimates'] = $statistics->getUserEstimates($aRoundShares, $aUser['shares'], $aUser['donate_percent'], $aUser['no_fees']); + } $aUsers[$iKey] = $aUser; } // Assign our variables diff --git a/public/include/pages/api/getdashboarddata.inc.php b/public/include/pages/api/getdashboarddata.inc.php index 5be24aee..ee5cdc70 100644 --- a/public/include/pages/api/getdashboarddata.inc.php +++ b/public/include/pages/api/getdashboarddata.inc.php @@ -58,22 +58,7 @@ if ($config['payout_system'] != 'pps') { $dUnpaidShares = 0; } else { $dUnpaidShares = $statistics->getUserUnpaidPPSShares($user_id, $setting->getValue('pps_last_share_id')); - if ($config['pps']['reward']['type'] == 'blockavg' && $block->getBlockCount() > 0) { - $pps_reward = round($block->getAvgBlockReward($config['pps']['blockavg']['blockcount'])); - } else { - if ($config['pps']['reward']['type'] == 'block') { - if ($aLastBlock = $block->getLast()) { - $pps_reward = $aLastBlock['amount']; - } else { - $pps_reward = $config['pps']['reward']['default']; - } - } else { - $pps_reward = $config['pps']['reward']['default']; - } - } - - $ppsvalue = round($pps_reward / (pow(2,32) * $dDifficulty) * pow(2, $config['target_bits']), 12); - $aEstimates = $statistics->getUserEstimates($dPersonalSharerate, $dPersonalShareDifficulty, $user->getUserDonatePercent($user_id), $user->getUserNoFee($user_id), $ppsvalue); + $aEstimates = $statistics->getUserEstimates($dPersonalSharerate, $dPersonalShareDifficulty, $user->getUserDonatePercent($user_id), $user->getUserNoFee($user_id), $statistics->getPPSValue()); } $iTotalRoundShares = $aRoundShares['valid'] + $aRoundShares['invalid']; diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index 6bf3b9b7..e6b601bb 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -136,24 +136,8 @@ if (@$_SESSION['USERDATA']['id']) { $aGlobal['userdata']['estimates'] = $aEstimates; break; case 'pps': - // We support some dynamic reward targets but fall back to our fixed value - // Special calculations for PPS Values based on reward_type setting and/or available blocks - if ($config['pps']['reward']['type'] == 'blockavg' && $block->getBlockCount() > 0) { - $pps_reward = round($block->getAvgBlockReward($config['pps']['blockavg']['blockcount'])); - } else { - if ($config['pps']['reward']['type'] == 'block') { - if ($aLastBlock = $block->getLast()) { - $pps_reward = $aLastBlock['amount']; - } else { - $pps_reward = $config['pps']['reward']['default']; - } - } else { - $pps_reward = $config['pps']['reward']['default']; - } - } - $aGlobal['userdata']['pps']['unpaidshares'] = $statistics->getUserUnpaidPPSShares($_SESSION['USERDATA']['id'], $setting->getValue('pps_last_share_id')); - $aGlobal['ppsvalue'] = number_format(round($pps_reward / (pow(2, $config['target_bits']) * $dDifficulty), 12) ,12); + $aGlobal['ppsvalue'] = number_format($statistics->getPPSValue(), 12); $aGlobal['poolppsvalue'] = $aGlobal['ppsvalue'] * pow(2, $config['difficulty'] - 16); $aGlobal['userdata']['sharedifficulty'] = $statistics->getUserShareDifficulty($_SESSION['USERDATA']['id']); $aGlobal['userdata']['estimates'] = $statistics->getUserEstimates($aGlobal['userdata']['sharerate'], $aGlobal['userdata']['sharedifficulty'], $aGlobal['userdata']['donate_percent'], $aGlobal['userdata']['no_fees'], $aGlobal['ppsvalue']); diff --git a/public/templates/mpos/admin/user/default.tpl b/public/templates/mpos/admin/user/default.tpl index 370fbbe8..7a8f2b0f 100644 --- a/public/templates/mpos/admin/user/default.tpl +++ b/public/templates/mpos/admin/user/default.tpl @@ -36,8 +36,12 @@