From b4a09f22eebda4b794c0a65c82df997b22eb2c34 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 10 Jun 2013 11:53:44 +0200 Subject: [PATCH] archive/purge accounted PPS shares --- cronjobs/pps_payout.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index 427035d5..efdbfc94 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -84,4 +84,22 @@ foreach ($aAccountShares as $aData) { $setting->setValue('pps_last_share_id', $iLastShareId); verbose("\n\n------------------------------------------------------------------------------------\n\n"); + +// Fetch all unaccounted blocks +$aAllBlocks = $block->getAllUnaccounted('ASC'); +if (empty($aAllBlocks)) { + verbose("No new unaccounted blocks found\n"); +} + +// Go through blocks and archive/delete shares that have been accounted for +foreach ($aAllBlocks as $iIndex => $aBlock) { + $dummy = $iIndex - 1; + if ($config['archive_shares'] && $aBlock['share_id'] < $iLastShareId) { + $share->moveArchive($aBlock['share_id'], $aBlock['id'], @$aAllBlocks[$dummy]['share_id']); + } + if ($aBlock['share_id'] < $iLastShareId && !$share->deleteAccountedShares($aBlock['share_id'], @$aAllBlocks[$dummy]['share_id'])) { + verbose("\nERROR : Failed to delete accounted shares from " . $aBlock['share_id'] . " to " . @$aAllBlocks[$dummy]['share_id'] . ", aborting!\n"); + exit(1); + } +} ?>