From c9435cf180d069a625aea2f6a14059af51f66cf4 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 30 Oct 2013 07:54:25 +0100 Subject: [PATCH] [FIX] Skip orphans for double payout detection Should fix the case where orphan blocks are followed by valid blocks with the same or lower height due to changing the main chain. Fixes $715, specifically the orphan block issue. --- cronjobs/pplns_payout.php | 8 +++++++- cronjobs/proportional_payout.php | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cronjobs/pplns_payout.php b/cronjobs/pplns_payout.php index 1fe17879..4d15d444 100755 --- a/cronjobs/pplns_payout.php +++ b/cronjobs/pplns_payout.php @@ -53,7 +53,13 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { $pplns_target = $config['pplns']['shares']['default']; } - if (!$aBlock['accounted'] && $aBlock['height'] > $setting->getValue('last_accounted_block_height')) { + if ($iLastBlockHeight = $setting->getValue('last_accounted_block_height')) { + $aLastAccountedBlock = $block->getBlock($iLastBlockHeight); + } else { + $iLastBlockHeight = 0; + } + // Double payout detection + if (!$aBlock['accounted'] && $aBlock['height'] > $iLastBlockHeight && @$aLastAccountedBlock['confirmations'] != -1) { $iPreviousShareId = @$aAllBlocks[$iIndex - 1]['share_id'] ? $aAllBlocks[$iIndex - 1]['share_id'] : 0; $iCurrentUpstreamId = $aBlock['share_id']; if (!is_numeric($iCurrentUpstreamId)) { diff --git a/cronjobs/proportional_payout.php b/cronjobs/proportional_payout.php index d863cc0d..0d34ed39 100755 --- a/cronjobs/proportional_payout.php +++ b/cronjobs/proportional_payout.php @@ -45,7 +45,12 @@ $count = 0; // Table header for account shares $log->logInfo("ID\tUsername\tValid\tInvalid\tPercentage\tPayout\t\tDonation\tFee"); foreach ($aAllBlocks as $iIndex => $aBlock) { - if (!$aBlock['accounted'] && $aBlock['height'] > $setting->getValue('last_accounted_block_height')) { + if ($iLastBlockHeight = $setting->getValue('last_accounted_block_height')) { + $aLastAccountedBlock = $block->getBlock($iLastBlockHeight); + } else { + $iLastBlockHeight = 0; + } + if (!$aBlock['accounted'] && $aBlock['height'] > $iLastBlockHeight && @$aLastAccountedBlock['confirmations'] != -1) { $iPreviousShareId = @$aAllBlocks[$iIndex - 1]['share_id'] ? $aAllBlocks[$iIndex - 1]['share_id'] : 0; $iCurrentUpstreamId = $aBlock['share_id']; $aAccountShares = $share->getSharesForAccounts($iPreviousShareId, $aBlock['share_id']);