From d155804a060797b9c7df51bfe5f2915f24818331 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 11 Nov 2013 12:51:06 +0100 Subject: [PATCH] [FIX] Skip payouts until block has a share_id --- cronjobs/pplns_payout.php | 7 +++++++ cronjobs/proportional_payout.php | 7 +++++++ public/include/config/error_codes.inc.php | 1 + 3 files changed, 15 insertions(+) diff --git a/cronjobs/pplns_payout.php b/cronjobs/pplns_payout.php index 73ce4a17..8d60ae2e 100755 --- a/cronjobs/pplns_payout.php +++ b/cronjobs/pplns_payout.php @@ -40,6 +40,12 @@ if (empty($aAllBlocks)) { $count = 0; foreach ($aAllBlocks as $iIndex => $aBlock) { + // If we have unaccounted blocks without share_ids, they might not have been inserted yet + if (!$aBlock['share_id']) { + $log->logError('E0062: Block has no share_id, not running payouts'); + $monitoring->endCronjob($cron_name, 'E0062', 0, true); + } + // We support some dynamic share targets but fall back to our fixed value // Re-calculate after each run due to re-targets in this loop if ($config['pplns']['shares']['type'] == 'blockavg' && $block->getBlockCount() > 0) { @@ -50,6 +56,7 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { $pplns_target = $config['pplns']['shares']['default']; } + // Fetch our last paid block information if ($iLastBlockId = $setting->getValue('last_accounted_block_id')) { $aLastAccountedBlock = $block->getBlockById($iLastBlockId); } else { diff --git a/cronjobs/proportional_payout.php b/cronjobs/proportional_payout.php index 49ab7a94..59819b29 100755 --- a/cronjobs/proportional_payout.php +++ b/cronjobs/proportional_payout.php @@ -42,6 +42,13 @@ $count = 0; // Table header for account shares $log->logInfo("ID\tUsername\tValid\tInvalid\tPercentage\tPayout\t\tDonation\tFee"); foreach ($aAllBlocks as $iIndex => $aBlock) { + // If we have unaccounted blocks without share_ids, they might not have been inserted yet + if (!$aBlock['share_id']) { + $log->logError('E0062: Block has no share_id, not running payouts'); + $monitoring->endCronjob($cron_name, 'E0062', 0, true); + } + + // Fetch last paid block information if ($iLastBlockId = $setting->getValue('last_accounted_block_id')) { $aLastAccountedBlock = $block->getBlockById($iLastBlockId); } else { diff --git a/public/include/config/error_codes.inc.php b/public/include/config/error_codes.inc.php index b48622c3..5eda21da 100644 --- a/public/include/config/error_codes.inc.php +++ b/public/include/config/error_codes.inc.php @@ -65,4 +65,5 @@ $aErrorCodes['E0058'] = 'Worker name and/or password must not be empty'; $aErrorCodes['E0059'] = 'Worker already exists'; $aErrorCodes['E0060'] = 'Failed to add new worker'; $aErrorCodes['E0061'] = 'Failed to delete worker'; +$aErrorCodes['E0062'] = 'Block has no share_id, not running payouts'; ?>