|
40 | 40 |
|
41 | 41 | $count = 0; |
42 | 42 | // Table header for account shares |
43 | | -$strLogMask = "| %10.10s | %-5.5s | %15.15s | %15.15s | %12.12s | %20.20s | %20.20s | %20.20s |"; |
44 | | -$log->logInfo(sprintf($strLogMask, 'Block', 'ID', 'Username', 'Valid', 'Invalid', 'Percentage', 'Payout', 'Donation', 'Fee')); |
| 43 | +$strLogMask = "| %10.10s | %-5.5s | %15.15s | %15.15s | %12.12s | %12.12s | %15.15s | %15.15s | %15.15s | %15.15s |"; |
| 44 | +$log->logInfo(sprintf($strLogMask, 'Block', 'ID', 'Username', 'Valid', 'Invalid', 'Percentage', 'Payout', 'Donation', 'Fee', 'Bonus')); |
45 | 45 | foreach ($aAllBlocks as $iIndex => $aBlock) { |
46 | 46 | // If we have unaccounted blocks without share_ids, they might not have been inserted yet |
47 | 47 | if (!$aBlock['share_id']) { |
|
86 | 86 | // Defaults |
87 | 87 | $aData['fee' ] = 0; |
88 | 88 | $aData['donation'] = 0; |
| 89 | + $aData['pool_bonus'] = 0; |
89 | 90 | $aData['percentage'] = round(( 100 / $iRoundShares ) * $aData['valid'], 8); |
90 | 91 | $aData['payout'] = round(( $aData['percentage'] / 100 ) * $dReward, 8); |
91 | 92 |
|
| 93 | + // Calculate pool fees if they apply |
92 | 94 | if ($config['fees'] > 0 && $aData['no_fees'] == 0) |
93 | 95 | $aData['fee'] = round($config['fees'] / 100 * $aData['payout'], 8); |
| 96 | + |
| 97 | + // Calculate pool bonus if it applies, will be paid from liquid assets! |
| 98 | + if ($config['pool_bonus'] > 0) { |
| 99 | + if ($config['pool_bonus_type'] == 'block') { |
| 100 | + $aData['pool_bonus'] = round(( $config['pool_bonus'] / 100 ) * $dReward, 8); |
| 101 | + } else { |
| 102 | + $aData['pool_bonus'] = round(( $config['pool_bonus'] / 100 ) * $aData['payout'], 8); |
| 103 | + } |
| 104 | + } |
| 105 | + |
94 | 106 | // Calculate donation amount, fees not included |
95 | 107 | $aData['donation'] = round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']), 8); |
96 | 108 |
|
97 | 109 | // Verbose output of this users calculations |
98 | 110 | $log->logInfo( |
99 | 111 | sprintf($strLogMask, $aBlock['height'], $aData['id'], $aData['username'], $aData['valid'], $aData['invalid'], |
100 | | - number_format($aData['percentage'], 8), number_format($aData['payout'], 8), number_format($aData['donation'], 8), number_format($aData['fee'], 8)) |
| 112 | + number_format($aData['percentage'], 8), number_format($aData['payout'], 8), number_format($aData['donation'], 8), number_format($aData['fee'], 8), number_format($aData['pool_bonus'], 8)) |
101 | 113 | ); |
102 | 114 |
|
103 | 115 | // Update user share statistics |
|
114 | 126 | if ($aData['donation'] > 0) |
115 | 127 | if (!$transaction->addTransaction($aData['id'], $aData['donation'], 'Donation', $aBlock['id'])) |
116 | 128 | $log->logFatal('Failed to insert new Donation transaction to database for ' . $aData['username'] . ': ' . $transaction->getCronError()); |
| 129 | + // Add new bonus credit |
| 130 | + if ($aData['pool_bonus'] > 0) |
| 131 | + if (!$transaction->addTransaction($aData['id'], $aData['pool_bonus'], 'Bonus', $aBlock['id'])) |
| 132 | + $log->logFatal('Failed to insert new Bonus transaction to database for ' . $aData['username'] . ': ' . $transaction->getCronError()); |
117 | 133 | } |
118 | 134 |
|
119 | 135 | // Add block as accounted for into settings table |
|
0 commit comments