From 67a4713cf025afc419ae7309ada53a52c7009334 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 21 Mar 2014 11:51:34 +0100 Subject: [PATCH] [REMOVED] Baseline Share calculations * We now track diff1 shares instead of converting into a baselined value * PPS has been adjusted to payout shares directly * Estimated Shares in coin_base adjusted --- cronjobs/pps_payout.php | 7 +++---- public/include/classes/coins/coin_base.class.php | 2 +- public/include/classes/share.class.php | 10 +++++----- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index cc1cbad1..509176d2 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -105,9 +105,8 @@ foreach ($aAccountShares as $aData) { continue; } - // MPOS uses a base difficulty setting to avoid showing weightened shares - // Since we need weightened shares here, we go back to the proper value for payouts - $aData['payout'] = round($aData['valid'] * pow(2, ($config['difficulty'] - 16)) * $pps_value, 12); + // Payout for this user + $aData['payout'] = round($aData['valid'] * $pps_value, 12); // Defaults $aData['fee' ] = 0; @@ -120,7 +119,7 @@ foreach ($aAccountShares as $aData) { $aData['donation'] = round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']), 12); $log->logInfo(sprintf( - $strLogMask, $aData['id'], $aData['username'], $aData['invalid'], $aData['valid'] * pow(2, ($config['difficulty'] - 16)), + $strLogMask, $aData['id'], $aData['username'], $aData['invalid'], $aData['valid'], number_format($pps_value, 12), number_format($aData['payout'], 12), number_format($aData['donation'], 12), number_format($aData['fee'], 12) )); diff --git a/public/include/classes/coins/coin_base.class.php b/public/include/classes/coins/coin_base.class.php index 64e412e2..1eb5470c 100644 --- a/public/include/classes/coins/coin_base.class.php +++ b/public/include/classes/coins/coin_base.class.php @@ -40,7 +40,7 @@ class CoinBase extends Base { * according to our configuration difficulty **/ public function calcEstaimtedShares($dDifficulty) { - return (int)round((pow(2, (32 - $this->target_bits)) * $dDifficulty) / pow(2, ($this->config['difficulty'] - 16))); + return (int)round(pow(2, (32 - $this->target_bits)) * $dDifficulty, 0); } /** diff --git a/public/include/classes/share.class.php b/public/include/classes/share.class.php index 0d11c4d5..3dd0e573 100644 --- a/public/include/classes/share.class.php +++ b/public/include/classes/share.class.php @@ -75,7 +75,7 @@ class Share Extends Base { **/ public function getRoundShares($previous_upstream=0, $current_upstream) { $stmt = $this->mysqli->prepare("SELECT - ROUND(IFNULL(SUM(IF(s.difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty)), 0) / POW(2, (" . $this->config['difficulty'] . " - 16)), 8) AS total + IFNULL(SUM(IF(s.difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty)), 0) AS total FROM $this->table AS s LEFT JOIN " . $this->user->getTableName() . " AS a ON a.username = SUBSTRING_INDEX( s.username , '.', 1 ) @@ -99,8 +99,8 @@ class Share Extends Base { a.id, SUBSTRING_INDEX( s.username , '.', 1 ) as username, a.no_fees AS no_fees, - ROUND(IFNULL(SUM(IF(our_result='Y', IF(s.difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 0) / POW(2, (" . $this->config['difficulty'] . " - 16)), 8) AS valid, - ROUND(IFNULL(SUM(IF(our_result='N', IF(s.difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 0) / POW(2, (" . $this->config['difficulty'] . " - 16)), 8) AS invalid + IFNULL(SUM(IF(our_result='Y', IF(s.difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 0) AS valid, + IFNULL(SUM(IF(our_result='N', IF(s.difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 0) AS invalid FROM $this->table AS s LEFT JOIN " . $this->user->getTableName() . " AS a ON a.username = SUBSTRING_INDEX( s.username , '.', 1 ) @@ -146,8 +146,8 @@ class Share Extends Base { a.id, SUBSTRING_INDEX( s.username , '.', 1 ) as account, a.no_fees AS no_fees, - ROUND(IFNULL(SUM(IF(our_result='Y', IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 0) / POW(2, (" . $this->config['difficulty'] . " - 16)), 8) AS valid, - ROUND(IFNULL(SUM(IF(our_result='N', IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 0) / POW(2, (" . $this->config['difficulty'] . " - 16)), 8) AS invalid + IFNULL(SUM(IF(our_result='Y', IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 0) AS valid, + IFNULL(SUM(IF(our_result='N', IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 0) AS invalid FROM $this->tableArchive AS s LEFT JOIN " . $this->user->getTableName() . " AS a ON a.username = SUBSTRING_INDEX( s.username , '.', 1 )