From 2204b6d9f3c85988ee2a2cb57cb91d4444ee3254 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 20 Jun 2013 16:49:53 +0200 Subject: [PATCH] Adding support to pay out full block amount * Configuration setting added: `reward_type` * Default behaviour: `fixed` payout by `reward` setting * Optional: `block` to payout full block amount to users Fixes #76 --- cronjobs/findblock.php | 3 ++- cronjobs/proportional_payout.php | 3 ++- public/include/config/global.inc.dist.php | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cronjobs/findblock.php b/cronjobs/findblock.php index e68d9ff4..ae08af72 100755 --- a/cronjobs/findblock.php +++ b/cronjobs/findblock.php @@ -72,7 +72,7 @@ if (empty($aAllBlocks)) { verbose("No new unaccounted blocks found\n"); } else { // Loop through our unaccounted blocks - verbose("\nBlock ID\tBlock Height\tShare ID\tShares\tFinder\t\t\tStatus\n"); + verbose("\nBlock ID\tBlock Height\tAmount\tShare ID\tShares\tFinder\t\t\tStatus\n"); foreach ($aAllBlocks as $iIndex => $aBlock) { if (empty($aBlock['share_id'])) { // Fetch this blocks upstream ID @@ -107,6 +107,7 @@ if (empty($aAllBlocks)) { verbose( $aBlock['id'] . "\t\t" . $aBlock['height'] . "\t\t" + . $aBlock['amount'] . "\t" . $iCurrentUpstreamId . "\t\t" . $iRoundShares . "\t" . "[$iAccountId] " . $user->getUserName($iAccountId) . "\t\t" diff --git a/cronjobs/proportional_payout.php b/cronjobs/proportional_payout.php index 61092006..57b97c2c 100755 --- a/cronjobs/proportional_payout.php +++ b/cronjobs/proportional_payout.php @@ -42,6 +42,7 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { $iCurrentUpstreamId = $aBlock['share_id']; $aAccountShares = $share->getSharesForAccounts($iPreviousShareId, $aBlock['share_id']); $iRoundShares = $share->getRoundShares($iPreviousShareId, $aBlock['share_id']); + $config['reward_type'] == 'block' ? $dReward = $aBlock['amount'] : $dReward = $config['reward']; if (empty($aAccountShares)) { verbose("\nNo shares found for this block\n\n"); @@ -56,7 +57,7 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { foreach ($aAccountShares as $key => $aData) { // Payout based on shares, PPS system $aData['percentage'] = number_format(round(( 100 / $iRoundShares ) * $aData['valid'], 8), 8); - $aData['payout'] = number_format(round(( $aData['percentage'] / 100 ) * $config['reward'], 8), 8); + $aData['payout'] = number_format(round(( $aData['percentage'] / 100 ) * $dReward, 8), 8); // Defaults $aData['fee' ] = 0; $aData['donation'] = 0; diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php index 3d677814..88513da0 100644 --- a/public/include/config/global.inc.dist.php +++ b/public/include/config/global.inc.dist.php @@ -60,6 +60,7 @@ $config = array( 'fees' => 0, 'difficulty' => '20', // Target difficulty for this pool as set in pushpoold json 'reward' => '50', // Reward for finding blocks, fixed value but changes someday + 'reward_type' => 'fixed', // Payout `fixed` reward as defined in reward or `block` amount 'confirmations' => '120', // Confirmations per block needed to credit transactions 'memcache' => array( 'enabled' => true,