diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index fc91645f..987b5f17 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -71,18 +71,24 @@ $log->logInfo("\tPPS value: " . $pps_value); // Find our last share accounted and last inserted share for PPS calculations if (!$iPreviousShareId = $setting->getValue('pps_last_share_id')) { - $log->logError("Failed to fetch Previous Share ID. ERROR: " . $setting->getCronError()); + $log->logError("Failed to fetch Previous Share ID. This is okay on your first run or when without any shares. ERROR: " . $setting->getCronError()); + $iPreviousShareId = 0; } -$log->logInfo("\tPPS Last Share ID: " . $iPreviousShareId); +$log->logInfo("\tPPS last paid out share ID: " . $iPreviousShareId); if (!$iLastShareId = $share->getLastInsertedShareId()) { $log->logError("Failed to fetch Last Inserted PPS Share ID. ERROR: " . $share->getCronError()); } -$log->logInfo("\tPPS Last Processed Share ID: " . $iLastShareId); +$log->logInfo("\tPPS last inserted share ID: " . $iLastShareId); + +if ($iPreviousShareId >= $iLastShareId) { + $log->logInfo('Not enough shares to account for, aborting until next run'); + $monitoring->endCronjob($cron_name, 'E0080', 0, true, false); +} // Check for all new shares, we start one higher as our last accounted share to avoid duplicates $log->logInfo("\tQuery getSharesForAccounts... starting..."); -if (!$aAccountShares = $share->getSharesForAccounts($iPreviousShareId + 1, $iLastShareId)) { +if (!$aAccountShares = $share->getSharesForAccounts($iPreviousShareId, $iLastShareId)) { $log->logError("Failed to fetch Account Shares. ERROR: " . $share->getCronError()); } $log->logInfo("\tQuery Completed..."); diff --git a/public/include/config/error_codes.inc.php b/public/include/config/error_codes.inc.php index 93ec3d3c..d8be9eb3 100644 --- a/public/include/config/error_codes.inc.php +++ b/public/include/config/error_codes.inc.php @@ -75,4 +75,5 @@ $aErrorCodes['E0076'] = 'No coins in wallet available'; $aErrorCodes['E0077'] = 'RPC method or connection failed'; $aErrorCodes['E0078'] = 'RPC method did not return 200 OK'; $aErrorCodes['E0079'] = 'Wallet does not cover payouts total amount'; +$aErrorCodes['E0080'] = 'No new unaccounted shares since last run'; ?>