From 8809e3df536c840fcda7d1369dc1cc1cc8d0ae5c Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 6 Aug 2013 10:26:27 +0200 Subject: [PATCH] Do not use number_format for inserting to DB This will fix an issue with very large payouts not being inserted to the DB properly. Moved number formatting to displaying output as it should be. --- cronjobs/pps_payout.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index 58c9b870..840d931a 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -68,7 +68,7 @@ if ($config['pps']['reward']['type'] == 'blockavg' && $block->getBlockCount() > } } -$pps_value = number_format(round($pps_reward / (pow(2,32) * $dDifficulty) * pow(2, $config['pps_target']), 12) ,12); +$pps_value = round($pps_reward / (pow(2,32) * $dDifficulty) * pow(2, $config['pps_target']), 12); //$pps_value = number_format(round((1/(65536 * $dDifficulty) * $pps_reward), 12) ,12); // Find our last share accounted and last inserted share for PPS calculations @@ -82,7 +82,7 @@ $log->logInfo("ID\tUsername\tInvalid\tValid\t\tPPS Value\t\tPayout\t\tDonation\t foreach ($aAccountShares as $aData) { // Take our valid shares and multiply by per share value - $aData['payout'] = number_format(round($aData['valid'] * $pps_value, 8), 8); + $aData['payout'] = round($aData['valid'] * $pps_value, 8); // Defaults $aData['fee' ] = 0; @@ -90,18 +90,18 @@ foreach ($aAccountShares as $aData) { // Calculate block fees if ($config['fees'] > 0 && $aData['no_fees'] == 0) - $aData['fee'] = number_format(round($config['fees'] / 100 * $aData['payout'], 8), 8); + $aData['fee'] = round($config['fees'] / 100 * $aData['payout'], 8); // Calculate donation amount - $aData['donation'] = number_format(round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']), 8), 8); + $aData['donation'] = round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']), 8); $log->logInfo($aData['id'] . "\t" . $aData['username'] . "\t" . $aData['invalid'] . "\t" . $aData['valid'] . "\t*\t" . - $pps_value . "\t=\t" . - $aData['payout'] . "\t" . - $aData['donation'] . "\t" . - $aData['fee']); + number_format($pps_value, 12) . "\t=\t" . + number_format($aData['payout'], 8) . "\t" . + number_format($aData['donation'], 8) . "\t" . + number_format($aData['fee'], 8)); // Add new credit transaction if (!$transaction->addTransaction($aData['id'], $aData['payout'], 'Credit_PPS'))