Skip to content

Commit

Permalink
[FIX] PPS Payout processing
Browse files Browse the repository at this point in the history
* [ADDED] Abort if we don't have enough shares to calculate PPS from
* [FIXED] Proper calculations for account shares, we dropped a share
  each run
* [ADDED] Error code if no new shares available
  • Loading branch information
MPOS123 committed Feb 14, 2014
1 parent 6f706b8 commit f43a521
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cronjobs/pps_payout.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,24 @@
// 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...");
Expand Down
1 change: 1 addition & 0 deletions public/include/config/error_codes.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@
$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';
?>

0 comments on commit f43a521

Please sign in to comment.