From f20719720d06c9fff6d7efae3da9421f1fa336e0 Mon Sep 17 00:00:00 2001 From: Neozonz Date: Mon, 20 Jan 2014 21:13:02 -0500 Subject: [PATCH 01/19] [Enhance] Improved logging [Fix] Added error messaging to all --- cronjobs/payouts.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cronjobs/payouts.php b/cronjobs/payouts.php index 87b5e119..51cdde1d 100755 --- a/cronjobs/payouts.php +++ b/cronjobs/payouts.php @@ -58,17 +58,17 @@ if ($setting->getValue('disable_manual_payouts') != 1) { try { $aStatus = $bitcoin->validateaddress($aData['coin_address']); if (!$aStatus['isvalid']) { - $log->logError('Failed to verify this users coin address, skipping payout'); + $log->logError('Skipping payment. Failed to verify coin address: ' . $aData['coin_address'] . ' ERROR: ' . $e->getMessage()); continue; } } catch (Exception $e) { - $log->logError('Failed to verify this users coin address, skipping payout'); + $log->logError('Skipping payment. RPC ERROR: ' . $e->getMessage()); continue; } try { $txid = $bitcoin->sendtoaddress($aData['coin_address'], $dBalance - $config['txfee_manual']); } catch (Exception $e) { - $log->logError('Failed to send requested balance to coin address, please check payout process. Does the wallet cover the amount? Error:' . $e->getMessage()); + $log->logError('Skipping payment. Failed to send balance to coin address: ' . $aData['coin_address'] . ' ERROR: ' . . $e->getMessage()); continue; } @@ -120,11 +120,11 @@ if ($setting->getValue('disable_auto_payouts') != 1) { try { $aStatus = $bitcoin->validateaddress($aUserData['coin_address']); if (!$aStatus['isvalid']) { - $log->logError('Failed to verify this users coin address, skipping payout'); + $log->logError('Skipping payment. Failed to verify coin address: ' . $aData['coin_address'] . ' ERROR: ' . $e->getMessage()); continue; } } catch (Exception $e) { - $log->logError('Failed to verify this users coin address, skipping payout'); + $log->logError('Skipping payment. RPC ERROR: ' . $e->getMessage()); continue; } @@ -132,7 +132,7 @@ if ($setting->getValue('disable_auto_payouts') != 1) { try { $txid = $bitcoin->sendtoaddress($aUserData['coin_address'], $dBalance - $config['txfee_auto']); } catch (Exception $e) { - $log->logError('Failed to send requested balance to coin address, please check payout process. Does the wallet cover the amount?'); + $log->logError('Skipping payment. Failed to send balance to coin address: ' . $aData['coin_address'] . ' ERROR: ' . . $e->getMessage()); continue; } From 08a3f123683a8a83f9a31b0fef3e5ce9bb688e17 Mon Sep 17 00:00:00 2001 From: Neozonz Date: Mon, 20 Jan 2014 22:20:02 -0500 Subject: [PATCH 02/19] [Enhance] PPS / Payout Crons - Improved logging and and improved fail safes [Optimize] Removed Coin Daemon / RPC Address Validation --- cronjobs/payouts.php | 60 ++++++++++++++++++----------------------- cronjobs/pps_payout.php | 48 ++++++++++++++++++++++++++++----- 2 files changed, 67 insertions(+), 41 deletions(-) diff --git a/cronjobs/payouts.php b/cronjobs/payouts.php index 51cdde1d..27dbd8f1 100755 --- a/cronjobs/payouts.php +++ b/cronjobs/payouts.php @@ -29,7 +29,7 @@ if ($setting->getValue('disable_payouts') == 1) { $log->logInfo(" payouts disabled via admin panel"); $monitoring->endCronjob($cron_name, 'E0009', 0, true, false); } - +$log->logInfo("Starting Payout..."); if ($bitcoin->can_connect() !== true) { $log->logFatal(" unable to connect to RPC server, exiting"); $monitoring->endCronjob($cron_name, 'E0006', 1, true); @@ -37,10 +37,15 @@ if ($bitcoin->can_connect() !== true) { if ($setting->getValue('disable_manual_payouts') != 1) { // Fetch outstanding payout requests - $aPayouts = $oPayout->getUnprocessedPayouts(); + if (!$aPayouts = $oPayout->getUnprocessedPayouts()) { + $log->logFatal("\tFailed Processing Manual Payment Queue..."); + $monitoring->endCronjob($cron_name, 'E0050', 1, true); + } + if (count($aPayouts > 0)) $log->logDebug(" found " . count($aPayouts) . " queued manual payout requests"); if (count($aPayouts) > 0) { + $log->logInfo("\tStarting Manual Payments..."); $log->logInfo("\tAccount ID\tUsername\tBalance\t\tCoin Address"); foreach ($aPayouts as $aData) { $aBalance = $transaction->getBalance($aData['account_id']); @@ -50,21 +55,11 @@ if ($setting->getValue('disable_manual_payouts') != 1) { if ($dBalance > $config['txfee_manual']) { // To ensure we don't run this transaction again, lets mark it completed if (!$oPayout->setProcessed($aData['id'])) { - $log->logFatal('unable to mark transactions ' . $aData['id'] . ' as processed.'); + $log->logFatal('unable to mark transactions ' . $aData['id'] . ' as processed. ERROR: ' . $oPayout->getCronError()); $monitoring->endCronjob($cron_name, 'E0010', 1, true); } $log->logInfo("\t" . $aData['account_id'] . "\t\t" . $aData['username'] . "\t" . $dBalance . "\t\t" . $aData['coin_address']); - try { - $aStatus = $bitcoin->validateaddress($aData['coin_address']); - if (!$aStatus['isvalid']) { - $log->logError('Skipping payment. Failed to verify coin address: ' . $aData['coin_address'] . ' ERROR: ' . $e->getMessage()); - continue; - } - } catch (Exception $e) { - $log->logError('Skipping payment. RPC ERROR: ' . $e->getMessage()); - continue; - } try { $txid = $bitcoin->sendtoaddress($aData['coin_address'], $dBalance - $config['txfee_manual']); } catch (Exception $e) { @@ -75,22 +70,25 @@ if ($setting->getValue('disable_manual_payouts') != 1) { if ($transaction->addTransaction($aData['account_id'], $dBalance - $config['txfee_manual'], 'Debit_MP', NULL, $aData['coin_address'], $txid) && $transaction->addTransaction($aData['account_id'], $config['txfee_manual'], 'TXFee', NULL, $aData['coin_address'])) { // Mark all older transactions as archived if (!$transaction->setArchived($aData['account_id'], $transaction->insert_id)) - $log->logError('Failed to mark transactions for #' . $aData['account_id'] . ' prior to #' . $transaction->insert_id . ' as archived'); + $log->logError('Failed to mark transactions for #' . $aData['account_id'] . ' prior to #' . $transaction->insert_id . ' as archived. ERROR: ' . $transaction->getCronError()); // Notify user via mail $aMailData['email'] = $user->getUserEmail($user->getUserName($aData['account_id'])); $aMailData['subject'] = 'Manual Payout Completed'; $aMailData['amount'] = $dBalance - $config['txfee_manual']; $aMailData['payout_id'] = $aData['id']; if (!$notification->sendNotification($aData['account_id'], 'manual_payout', $aMailData)) - $log->logError('Failed to send notification email to users address: ' . $aMailData['email']); + $log->logError('Failed to send notification email to users address: ' . $aMailData['email'] . 'ERROR: ' . $notification->getCronError()); // Recheck the users balance to make sure it is now 0 - $aBalance = $transaction->getBalance($aData['account_id']); + if (!$aBalance = $transaction->getBalance($aData['account_id']) { + $log->logFatal('Failed to fetch balance for account ' . $aData['account_id'] . '. ERROR: ' . $transaction->getCronError()); + $monitoring->endCronjob($cron_name, 'E0065', 1, true); + } if ($aBalance['confirmed'] > 0) { $log->logFatal('User has a remaining balance of ' . $aBalance['confirmed'] . ' after a successful payout!'); $monitoring->endCronjob($cron_name, 'E0065', 1, true); } } else { - $log->logFatal('Failed to add new Debit_MP transaction in database for user ' . $user->getUserName($aData['account_id'])); + $log->logFatal('Failed to add new Debit_MP transaction in database for user ' . $user->getUserName($aData['account_id']) . ' ERROR: ' . $notification->getCronError());); $monitoring->endCronjob($cron_name, 'E0064', 1, true); } } @@ -103,11 +101,15 @@ if ($setting->getValue('disable_manual_payouts') != 1) { if ($setting->getValue('disable_auto_payouts') != 1) { // Fetch all users balances - $users = $transaction->getAPQueue(); + if (!$users = $transaction->getAPQueue()) { + $log->logFatal("\tFailed Processing Auto Payment Payment Queue. ERROR: " . $share->getCronError()); + $monitoring->endCronjob($cron_name, 'E0050', 1, true); + } if (count($users) > 0) $log->logDebug(" found " . count($users) . " queued payout(s)"); // Go through users and run transactions if (! empty($users)) { + $log->logInfo("\tStarting Auto Payments..."); $log->logInfo("\tUserID\tUsername\tBalance\tThreshold\tAddress"); foreach ($users as $aUserData) { @@ -116,18 +118,6 @@ if ($setting->getValue('disable_auto_payouts') != 1) { // Only run if balance meets threshold and can pay the potential transaction fee if ($dBalance > $aUserData['ap_threshold'] && $dBalance > $config['txfee_auto']) { - // Validate address against RPC - try { - $aStatus = $bitcoin->validateaddress($aUserData['coin_address']); - if (!$aStatus['isvalid']) { - $log->logError('Skipping payment. Failed to verify coin address: ' . $aData['coin_address'] . ' ERROR: ' . $e->getMessage()); - continue; - } - } catch (Exception $e) { - $log->logError('Skipping payment. RPC ERROR: ' . $e->getMessage()); - continue; - } - // Send balance, fees are reduced later by RPC Server try { $txid = $bitcoin->sendtoaddress($aUserData['coin_address'], $dBalance - $config['txfee_auto']); @@ -140,13 +130,13 @@ if ($setting->getValue('disable_auto_payouts') != 1) { if ($transaction->addTransaction($aUserData['id'], $dBalance - $config['txfee_auto'], 'Debit_AP', NULL, $aUserData['coin_address'], $txid) && $transaction->addTransaction($aUserData['id'], $config['txfee_auto'], 'TXFee', NULL, $aUserData['coin_address'])) { // Mark all older transactions as archived if (!$transaction->setArchived($aUserData['id'], $transaction->insert_id)) - $log->logError('Failed to mark transactions for user #' . $aUserData['id'] . ' prior to #' . $transaction->insert_id . ' as archived'); + $log->logError('Failed to mark transactions for user #' . $aUserData['id'] . ' prior to #' . $transaction->insert_id . ' as archived. ERROR: ' . $transaction->getCronError()); // Notify user via mail $aMailData['email'] = $user->getUserEmail($user->getUserName($aUserData['id'])); $aMailData['subject'] = 'Auto Payout Completed'; $aMailData['amount'] = $dBalance - $config['txfee_auto']; if (!$notification->sendNotification($aUserData['id'], 'auto_payout', $aMailData)) - $log->logError('Failed to send notification email to users address: ' . $aMailData['email']); + $log->logError('Failed to send notification email to users address: ' . $aMailData['email'] . ' ERROR: ' . $notification->getCronError()); // Recheck the users balance to make sure it is now 0 $aBalance = $transaction->getBalance($aUserData['id']); if ($aBalance['confirmed'] > 0) { @@ -154,17 +144,19 @@ if ($setting->getValue('disable_auto_payouts') != 1) { $monitoring->endCronjob($cron_name, 'E0065', 1, true); } } else { - $log->logFatal('Failed to add new Debit_AP transaction in database for user ' . $user->getUserName($aUserData['id'])); + $log->logFatal('Failed to add new Debit_AP transaction in database for user ' . $user->getUserName($aUserData['id']) . ' ERROR: ' . $notification->getCronError()); $monitoring->endCronjob($cron_name, 'E0064', 1, true); } } } } else { - $log->logDebug(" no user has configured their AP > 0"); + $log->logDebug("Users have not configured their AP > 0"); } } else { $log->logDebug("Auto payouts disabled via admin panel"); } +$log->logInfo("\tCompleted Payouts"); + // Cron cleanup and monitoring require_once('cron_end.inc.php'); ?> diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index 1c79e411..d33d5b56 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -31,6 +31,7 @@ if ($config['payout_system'] != 'pps') { $log->logInfo("Please activate this cron in configuration via payout_system = pps\n"); exit(0); } +$log->logInfo("Starting PPS Payout..."); // Fetch all transactions since our last block if ( $bitcoin->can_connect() === true ){ @@ -55,27 +56,45 @@ if ($config['pps']['reward']['type'] == 'blockavg' && $block->getBlockCount() > if ($config['pps']['reward']['type'] == 'block') { if ($aLastBlock = $block->getLast()) { $pps_reward = $aLastBlock['amount']; + $log->logInfo("PPS value (Last Block): " . $pps_reward); } else { $pps_reward = $config['pps']['reward']['default']; + $log->logInfo("PPS value (Default): " . $pps_reward); } } else { $pps_reward = $config['pps']['reward']['default']; + $log->logInfo("PPS value (Default): " . $pps_reward); } } // Per-share value to be paid out to users $pps_value = round($pps_reward / (pow(2, $config['target_bits']) * $dDifficulty), 12); +$log->logInfo("PPS value: " . $pps_value); // Find our last share accounted and last inserted share for PPS calculations -$iPreviousShareId = $setting->getValue('pps_last_share_id'); -$iLastShareId = $share->getLastInsertedShareId(); +$log->logInfo("PPS Previous Share ID: " . $iLastShareId); +if (!$iPreviousShareId = $setting->getValue('pps_last_share_id'); + $log->logError("Failed to fetch Previous Share ID. ERROR: " . $setting->getCronError()); +} + +$log->logInfo("PPS Last Share ID: " . $iPreviousShareId); +if (!$iLastShareId = $share->getLastInsertedShareId(); + $log->logError("Failed to fetch Last Inserted PPS Share ID. ERROR: " . $share->getCronError()); +} + + // Check for all new shares, we start one higher as our last accounted share to avoid duplicates -$aAccountShares = $share->getSharesForAccounts($iPreviousShareId + 1, $iLastShareId); +$log->logInfo("Query getSharesForAccounts... starting..."); +if (!$aAccountShares = $share->getSharesForAccounts($iPreviousShareId + 1, $iLastShareId)) { + $log->logError("Failed to fetch Account Shares. ERROR: " . $share->getCronError()); +} +$log->logInfo("Query Completed..."); if (!empty($aAccountShares)) { // Info for this payout $log->logInfo("PPS reward type: " . $config['pps']['reward']['type'] . ", amount: " . $pps_reward . "\tdifficulty: " . $dDifficulty . "\tPPS value: " . $pps_value); + $log->logInfo("Running through accounts to process shares..."); $log->logInfo("ID\tUsername\tInvalid\tValid\t\tPPS Value\t\tPayout\t\tDonation\tFee"); } @@ -123,18 +142,24 @@ foreach ($aAccountShares as $aData) { } // Store our last inserted ID for the next run -$setting->setValue('pps_last_share_id', $iLastShareId); +$log->logInfo("\tFetching Last Share ID..."); +if (!$setting->setValue('pps_last_share_id', $iLastShareId)) { + $log->logError("Failed to fetch Last Share ID. ERROR: " . $setting->getCronError()); +} // Fetch all unaccounted blocks +$log->logInfo("\tFetching unaccounted blocks."); $aAllBlocks = $block->getAllUnaccounted('ASC'); if (empty($aAllBlocks)) { - $log->logDebug("No new unaccounted blocks found"); + $log->logInfo("\tNo new blocks."); // No monitoring event here, not fatal for PPS } // Go through blocks and archive/delete shares that have been accounted for + foreach ($aAllBlocks as $iIndex => $aBlock) { // If we are running through more than one block, check for previous share ID + $log->logInfo("\tProcess each block for Previous Share ID."); $iLastBlockShare = @$aAllBlocks[$iIndex - 1]['share_id'] ? @$aAllBlocks[$iIndex - 1]['share_id'] : 0; if (!is_numeric($aBlock['share_id'])) { $log->logFatal("Block " . $aBlock['height'] . " has no share_id associated with it, not going to continue"); @@ -144,27 +169,36 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { exit(1); } // Per account statistics - $aAccountShares = $share->getSharesForAccounts(@$iLastBlockShare, $aBlock['share_id']); + $log->logInfo("\tStarting to store fresh user statistics..."); + if (!$aAccountShares = $share->getSharesForAccounts(@$iLastBlockShare, $aBlock['share_id'])) { + $log->logError("Failed to Account Shares. ERROR: " . $share->getCronError()); + } + foreach ($aAccountShares as $key => $aData) { if (!$statistics->updateShareStatistics($aData, $aBlock['id'])) - $log->logError("Failed to update stats for this block on : " . $aData['username'] . ': ' . $statistics->getCronError()); + $log->logError("Failed to update statistics for Block " . $aBlock['id'] . "for" . $aData['username'] . ' ERROR: ' . $statistics->getCronError()); } + // Move shares to archive + $log->logInfo("\tMove shares to archive..."); if ($aBlock['share_id'] < $iLastShareId) { if (!$share->moveArchive($aBlock['share_id'], $aBlock['id'], @$iLastBlockShare)) $log->logError("Failed to copy shares to archive: " . $share->getCronError() . ': ' . $share->getCronError()); } // Delete shares + $log->logInfo("\tDelete accounted shares..."); if ($aBlock['share_id'] < $iLastShareId && !$share->deleteAccountedShares($aBlock['share_id'], $iLastBlockShare)) { $log->logFatal("Failed to delete accounted shares from " . $aBlock['share_id'] . " to " . $iLastBlockShare . ", aborting! Error: " . $share->getCronError()); $monitoring->endCronjob($cron_name, 'E0016', 1, true); } // Mark this block as accounted for + $log->logInfo("\tMark Block as accounted"); if (!$block->setAccounted($aBlock['id'])) { $log->logFatal("Failed to mark block as accounted! Aborting! Error: " . $block->getCronError()); $monitoring->endCronjob($cron_name, 'E0014', 1, true); } } +$log->logInfo("Completed PPS Payout"); require_once('cron_end.inc.php'); ?> From 8c9119e4392724c654117da52c3d8953d669cb7b Mon Sep 17 00:00:00 2001 From: Neozonz Date: Mon, 20 Jan 2014 22:43:15 -0500 Subject: [PATCH 03/19] [FIX] Various syntax issues --- cronjobs/pps_payout.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index d33d5b56..13fb92cb 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -72,18 +72,16 @@ $pps_value = round($pps_reward / (pow(2, $config['target_bits']) * $dDifficulty) $log->logInfo("PPS value: " . $pps_value); // Find our last share accounted and last inserted share for PPS calculations -$log->logInfo("PPS Previous Share ID: " . $iLastShareId); -if (!$iPreviousShareId = $setting->getValue('pps_last_share_id'); +$log->logInfo("PPS Previous Share ID: " . $iLastShareId); +if (!$iPreviousShareId = $setting->getValue('pps_last_share_id') { $log->logError("Failed to fetch Previous Share ID. ERROR: " . $setting->getCronError()); } $log->logInfo("PPS Last Share ID: " . $iPreviousShareId); -if (!$iLastShareId = $share->getLastInsertedShareId(); +if (!$iLastShareId = $share->getLastInsertedShareId()) { $log->logError("Failed to fetch Last Inserted PPS Share ID. ERROR: " . $share->getCronError()); } - - // Check for all new shares, we start one higher as our last accounted share to avoid duplicates $log->logInfo("Query getSharesForAccounts... starting..."); if (!$aAccountShares = $share->getSharesForAccounts($iPreviousShareId + 1, $iLastShareId)) { @@ -149,14 +147,15 @@ if (!$setting->setValue('pps_last_share_id', $iLastShareId)) { // Fetch all unaccounted blocks $log->logInfo("\tFetching unaccounted blocks."); -$aAllBlocks = $block->getAllUnaccounted('ASC'); +if (!$aAllBlocks = $block->getAllUnaccounted('ASC')) { + $log->logInfo("Failed to fetch unaccounted Blocks. NOTICE: " . $block->getCronError()); +} if (empty($aAllBlocks)) { $log->logInfo("\tNo new blocks."); // No monitoring event here, not fatal for PPS } // Go through blocks and archive/delete shares that have been accounted for - foreach ($aAllBlocks as $iIndex => $aBlock) { // If we are running through more than one block, check for previous share ID $log->logInfo("\tProcess each block for Previous Share ID."); @@ -192,11 +191,12 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { $monitoring->endCronjob($cron_name, 'E0016', 1, true); } // Mark this block as accounted for - $log->logInfo("\tMark Block as accounted"); + $log->logInfo("\tMarking Block as accounted..."); if (!$block->setAccounted($aBlock['id'])) { $log->logFatal("Failed to mark block as accounted! Aborting! Error: " . $block->getCronError()); $monitoring->endCronjob($cron_name, 'E0014', 1, true); } + $log->logInfo("\tMarked Block" . $aBlock['id'] . " as accounted."); } $log->logInfo("Completed PPS Payout"); From daee9a87c1f85f26943aca389d70940a5faad86a Mon Sep 17 00:00:00 2001 From: Neozonz Date: Mon, 20 Jan 2014 23:06:03 -0500 Subject: [PATCH 04/19] [FIX] Call correct getCronError functions --- cronjobs/payouts.php | 6 +++--- cronjobs/pplns_payout.php | 6 +++--- cronjobs/pps_payout.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cronjobs/payouts.php b/cronjobs/payouts.php index 27dbd8f1..9a8081c6 100755 --- a/cronjobs/payouts.php +++ b/cronjobs/payouts.php @@ -88,7 +88,7 @@ if ($setting->getValue('disable_manual_payouts') != 1) { $monitoring->endCronjob($cron_name, 'E0065', 1, true); } } else { - $log->logFatal('Failed to add new Debit_MP transaction in database for user ' . $user->getUserName($aData['account_id']) . ' ERROR: ' . $notification->getCronError());); + $log->logFatal('Failed to add new Debit_MP transaction in database for user ' . $user->getUserName($aData['account_id']) . ' ERROR: ' . $transaction->getCronError());); $monitoring->endCronjob($cron_name, 'E0064', 1, true); } } @@ -102,7 +102,7 @@ if ($setting->getValue('disable_manual_payouts') != 1) { if ($setting->getValue('disable_auto_payouts') != 1) { // Fetch all users balances if (!$users = $transaction->getAPQueue()) { - $log->logFatal("\tFailed Processing Auto Payment Payment Queue. ERROR: " . $share->getCronError()); + $log->logFatal("\tFailed Processing Auto Payment Payment Queue. ERROR: " . $transaction->getCronError()); $monitoring->endCronjob($cron_name, 'E0050', 1, true); } if (count($users) > 0) $log->logDebug(" found " . count($users) . " queued payout(s)"); @@ -144,7 +144,7 @@ if ($setting->getValue('disable_auto_payouts') != 1) { $monitoring->endCronjob($cron_name, 'E0065', 1, true); } } else { - $log->logFatal('Failed to add new Debit_AP transaction in database for user ' . $user->getUserName($aUserData['id']) . ' ERROR: ' . $notification->getCronError()); + $log->logFatal('Failed to add new Debit_AP transaction in database for user ' . $user->getUserName($aUserData['id']) . ' ERROR: ' . $transaction->getCronError()); $monitoring->endCronjob($cron_name, 'E0064', 1, true); } } diff --git a/cronjobs/pplns_payout.php b/cronjobs/pplns_payout.php index c8e6626a..208c20c9 100755 --- a/cronjobs/pplns_payout.php +++ b/cronjobs/pplns_payout.php @@ -106,7 +106,7 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { // Grab only the most recent shares from Archive that fill the missing shares $log->logInfo('Fetching ' . ($pplns_target - $iRoundShares) . ' additional shares from archive'); if (!$aArchiveShares = $share->getArchiveShares($pplns_target - $iRoundShares)) { - $log->logError('Failed to fetch shares from archive, setting target to round total'); + $log->logError('Failed to fetch shares from archive, setting target to round total. Error: ' . $share->getCronError()); $pplns_target = $iRoundShares; } else { // Add archived shares to users current shares, if we have any in archive @@ -236,10 +236,10 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { // Move counted shares to archive before this blockhash upstream share if (!$share->moveArchive($iCurrentUpstreamId, $aBlock['id'], $iPreviousShareId)) - $log->logError('Failed to copy shares to archive table: ' . $share->getCronError() . ': ' . $share->getCronError()); + $log->logError('Failed to copy shares to archive table: ' . $iPreviousShareId . ' to ' . $iCurrentUpstreamId . ' aborting! Error: ' . $share->getCronError()); // Delete all accounted shares if (!$share->deleteAccountedShares($iCurrentUpstreamId, $iPreviousShareId)) { - $log->logFatal("Failed to delete accounted shares from $iPreviousShareId to $iCurrentUpstreamId, aborting! Error: " . $share->getCronError()); + $log->logFatal("Failed to delete accounted shares from " . $iPreviousShareId . " to " . $iCurrentUpstreamId . " aborting! Error: " . $share->getCronError()); $monitoring->endCronjob($cron_name, 'E0016', 1, true); } // Mark this block as accounted for diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index 13fb92cb..8c1e928f 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -182,7 +182,7 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { $log->logInfo("\tMove shares to archive..."); if ($aBlock['share_id'] < $iLastShareId) { if (!$share->moveArchive($aBlock['share_id'], $aBlock['id'], @$iLastBlockShare)) - $log->logError("Failed to copy shares to archive: " . $share->getCronError() . ': ' . $share->getCronError()); + $log->logError("Failed to copy shares to from " . $aBlock['share_id'] . " to " . $iLastBlockShare . ' Error: ' . $share->getCronError()); } // Delete shares $log->logInfo("\tDelete accounted shares..."); From 45c0506a455314a736a082e23a7c9998eb9432bd Mon Sep 17 00:00:00 2001 From: Neozonz Date: Tue, 21 Jan 2014 05:44:45 -0500 Subject: [PATCH 05/19] [FIX] Indenting --- cronjobs/payouts.php | 6 +++--- cronjobs/pps_payout.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cronjobs/payouts.php b/cronjobs/payouts.php index 9a8081c6..0433c518 100755 --- a/cronjobs/payouts.php +++ b/cronjobs/payouts.php @@ -80,9 +80,9 @@ if ($setting->getValue('disable_manual_payouts') != 1) { $log->logError('Failed to send notification email to users address: ' . $aMailData['email'] . 'ERROR: ' . $notification->getCronError()); // Recheck the users balance to make sure it is now 0 if (!$aBalance = $transaction->getBalance($aData['account_id']) { - $log->logFatal('Failed to fetch balance for account ' . $aData['account_id'] . '. ERROR: ' . $transaction->getCronError()); - $monitoring->endCronjob($cron_name, 'E0065', 1, true); - } + $log->logFatal('Failed to fetch balance for account ' . $aData['account_id'] . '. ERROR: ' . $transaction->getCronError()); + $monitoring->endCronjob($cron_name, 'E0065', 1, true); + } if ($aBalance['confirmed'] > 0) { $log->logFatal('User has a remaining balance of ' . $aBalance['confirmed'] . ' after a successful payout!'); $monitoring->endCronjob($cron_name, 'E0065', 1, true); diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index 8c1e928f..c7d79d30 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -56,14 +56,14 @@ if ($config['pps']['reward']['type'] == 'blockavg' && $block->getBlockCount() > if ($config['pps']['reward']['type'] == 'block') { if ($aLastBlock = $block->getLast()) { $pps_reward = $aLastBlock['amount']; - $log->logInfo("PPS value (Last Block): " . $pps_reward); + $log->logInfo("PPS value (Last Block): " . $pps_reward); } else { $pps_reward = $config['pps']['reward']['default']; - $log->logInfo("PPS value (Default): " . $pps_reward); + $log->logInfo("PPS value (Default): " . $pps_reward); } } else { $pps_reward = $config['pps']['reward']['default']; - $log->logInfo("PPS value (Default): " . $pps_reward); + $log->logInfo("PPS value (Default): " . $pps_reward); } } From 2ab7562790cb202d2ecccc43004c342b91e27cab Mon Sep 17 00:00:00 2001 From: Neozonz Date: Tue, 21 Jan 2014 05:53:35 -0500 Subject: [PATCH 06/19] [FIX] Indenting --- cronjobs/payouts.php | 4 ++-- cronjobs/pps_payout.php | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cronjobs/payouts.php b/cronjobs/payouts.php index 0433c518..f023e69b 100755 --- a/cronjobs/payouts.php +++ b/cronjobs/payouts.php @@ -102,8 +102,8 @@ if ($setting->getValue('disable_manual_payouts') != 1) { if ($setting->getValue('disable_auto_payouts') != 1) { // Fetch all users balances if (!$users = $transaction->getAPQueue()) { - $log->logFatal("\tFailed Processing Auto Payment Payment Queue. ERROR: " . $transaction->getCronError()); - $monitoring->endCronjob($cron_name, 'E0050', 1, true); + $log->logFatal("\tFailed Processing Auto Payment Payment Queue. ERROR: " . $transaction->getCronError()); + $monitoring->endCronjob($cron_name, 'E0050', 1, true); } if (count($users) > 0) $log->logDebug(" found " . count($users) . " queued payout(s)"); diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index c7d79d30..7f2f1279 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -74,18 +74,18 @@ $log->logInfo("PPS value: " . $pps_value); // Find our last share accounted and last inserted share for PPS calculations $log->logInfo("PPS Previous Share ID: " . $iLastShareId); 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. ERROR: " . $setting->getCronError()); } $log->logInfo("PPS Last Share ID: " . $iPreviousShareId); if (!$iLastShareId = $share->getLastInsertedShareId()) { - $log->logError("Failed to fetch Last Inserted PPS Share ID. ERROR: " . $share->getCronError()); + $log->logError("Failed to fetch Last Inserted PPS Share ID. ERROR: " . $share->getCronError()); } // Check for all new shares, we start one higher as our last accounted share to avoid duplicates $log->logInfo("Query getSharesForAccounts... starting..."); if (!$aAccountShares = $share->getSharesForAccounts($iPreviousShareId + 1, $iLastShareId)) { - $log->logError("Failed to fetch Account Shares. ERROR: " . $share->getCronError()); + $log->logError("Failed to fetch Account Shares. ERROR: " . $share->getCronError()); } $log->logInfo("Query Completed..."); @@ -142,13 +142,13 @@ foreach ($aAccountShares as $aData) { // Store our last inserted ID for the next run $log->logInfo("\tFetching Last Share ID..."); if (!$setting->setValue('pps_last_share_id', $iLastShareId)) { - $log->logError("Failed to fetch Last Share ID. ERROR: " . $setting->getCronError()); + $log->logError("Failed to fetch Last Share ID. ERROR: " . $setting->getCronError()); } // Fetch all unaccounted blocks $log->logInfo("\tFetching unaccounted blocks."); if (!$aAllBlocks = $block->getAllUnaccounted('ASC')) { - $log->logInfo("Failed to fetch unaccounted Blocks. NOTICE: " . $block->getCronError()); + $log->logInfo("Failed to fetch unaccounted Blocks. NOTICE: " . $block->getCronError()); } if (empty($aAllBlocks)) { $log->logInfo("\tNo new blocks."); @@ -170,7 +170,7 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { // Per account statistics $log->logInfo("\tStarting to store fresh user statistics..."); if (!$aAccountShares = $share->getSharesForAccounts(@$iLastBlockShare, $aBlock['share_id'])) { - $log->logError("Failed to Account Shares. ERROR: " . $share->getCronError()); + $log->logError("Failed to Account Shares. ERROR: " . $share->getCronError()); } foreach ($aAccountShares as $key => $aData) { From b8dddade5031fd9dad3b017eb9cbb1ed82d28304 Mon Sep 17 00:00:00 2001 From: Neozonz Date: Tue, 21 Jan 2014 08:17:24 -0500 Subject: [PATCH 07/19] [FIX] Whoops --- cronjobs/payouts.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cronjobs/payouts.php b/cronjobs/payouts.php index f023e69b..19053db6 100755 --- a/cronjobs/payouts.php +++ b/cronjobs/payouts.php @@ -63,7 +63,7 @@ if ($setting->getValue('disable_manual_payouts') != 1) { try { $txid = $bitcoin->sendtoaddress($aData['coin_address'], $dBalance - $config['txfee_manual']); } catch (Exception $e) { - $log->logError('Skipping payment. Failed to send balance to coin address: ' . $aData['coin_address'] . ' ERROR: ' . . $e->getMessage()); + $log->logError('Skipping payment. Failed to send balance to coin address: ' . $aData['coin_address'] . ' ERROR: ' . $e->getMessage()); continue; } @@ -122,7 +122,7 @@ if ($setting->getValue('disable_auto_payouts') != 1) { try { $txid = $bitcoin->sendtoaddress($aUserData['coin_address'], $dBalance - $config['txfee_auto']); } catch (Exception $e) { - $log->logError('Skipping payment. Failed to send balance to coin address: ' . $aData['coin_address'] . ' ERROR: ' . . $e->getMessage()); + $log->logError('Skipping payment. Failed to send balance to coin address: ' . $aData['coin_address'] . ' ERROR: ' . $e->getMessage()); continue; } From 55598daad58259be2a8d0327250dd95b7a99ed01 Mon Sep 17 00:00:00 2001 From: Neozonz Date: Tue, 21 Jan 2014 08:25:08 -0500 Subject: [PATCH 08/19] [FIX] Whoops --- cronjobs/payouts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cronjobs/payouts.php b/cronjobs/payouts.php index 19053db6..5e62c843 100755 --- a/cronjobs/payouts.php +++ b/cronjobs/payouts.php @@ -79,7 +79,7 @@ if ($setting->getValue('disable_manual_payouts') != 1) { if (!$notification->sendNotification($aData['account_id'], 'manual_payout', $aMailData)) $log->logError('Failed to send notification email to users address: ' . $aMailData['email'] . 'ERROR: ' . $notification->getCronError()); // Recheck the users balance to make sure it is now 0 - if (!$aBalance = $transaction->getBalance($aData['account_id']) { + if (!$aBalance = $transaction->getBalance($aData['account_id'])) { $log->logFatal('Failed to fetch balance for account ' . $aData['account_id'] . '. ERROR: ' . $transaction->getCronError()); $monitoring->endCronjob($cron_name, 'E0065', 1, true); } From 2840866513567ec23a7336957918b908d199afd4 Mon Sep 17 00:00:00 2001 From: Neozonz Date: Tue, 21 Jan 2014 08:27:42 -0500 Subject: [PATCH 09/19] [FIX] Woopsie --- cronjobs/payouts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cronjobs/payouts.php b/cronjobs/payouts.php index 5e62c843..972a8cf6 100755 --- a/cronjobs/payouts.php +++ b/cronjobs/payouts.php @@ -88,7 +88,7 @@ if ($setting->getValue('disable_manual_payouts') != 1) { $monitoring->endCronjob($cron_name, 'E0065', 1, true); } } else { - $log->logFatal('Failed to add new Debit_MP transaction in database for user ' . $user->getUserName($aData['account_id']) . ' ERROR: ' . $transaction->getCronError());); + $log->logFatal('Failed to add new Debit_MP transaction in database for user ' . $user->getUserName($aData['account_id']) . ' ERROR: ' . $transaction->getCronError()); $monitoring->endCronjob($cron_name, 'E0064', 1, true); } } From 58327a7884754badec280fe0503a1cccd82be228 Mon Sep 17 00:00:00 2001 From: Neozonz Date: Tue, 21 Jan 2014 20:45:34 -0500 Subject: [PATCH 10/19] [FIX] Missing Bracket --- cronjobs/pps_payout.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index 7f2f1279..345a7f02 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -73,7 +73,7 @@ $log->logInfo("PPS value: " . $pps_value); // Find our last share accounted and last inserted share for PPS calculations $log->logInfo("PPS Previous Share ID: " . $iLastShareId); -if (!$iPreviousShareId = $setting->getValue('pps_last_share_id') { +if (!$iPreviousShareId = $setting->getValue('pps_last_share_id')) { $log->logError("Failed to fetch Previous Share ID. ERROR: " . $setting->getCronError()); } From b81bf64bb06719954a9a1677d1d0b1dcba832775 Mon Sep 17 00:00:00 2001 From: Neozonz Date: Tue, 21 Jan 2014 20:49:22 -0500 Subject: [PATCH 11/19] [LOGGING] Improved wording [FIX] Call to variables before defined --- cronjobs/pps_payout.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index 345a7f02..864e8b83 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -72,15 +72,16 @@ $pps_value = round($pps_reward / (pow(2, $config['target_bits']) * $dDifficulty) $log->logInfo("PPS value: " . $pps_value); // Find our last share accounted and last inserted share for PPS calculations -$log->logInfo("PPS Previous Share ID: " . $iLastShareId); + if (!$iPreviousShareId = $setting->getValue('pps_last_share_id')) { $log->logError("Failed to fetch Previous Share ID. ERROR: " . $setting->getCronError()); } +$log->logInfo("PPS Last Share ID: " . $iPreviousShareId); -$log->logInfo("PPS Last Share ID: " . $iPreviousShareId); if (!$iLastShareId = $share->getLastInsertedShareId()) { $log->logError("Failed to fetch Last Inserted PPS Share ID. ERROR: " . $share->getCronError()); } +$log->logInfo("PPS Last Processed Share ID: " . $iLastShareId); // Check for all new shares, we start one higher as our last accounted share to avoid duplicates $log->logInfo("Query getSharesForAccounts... starting..."); From 8c97fb17585553259a1787baf2dd73199aa8c8d9 Mon Sep 17 00:00:00 2001 From: Neozonz Date: Tue, 21 Jan 2014 21:01:43 -0500 Subject: [PATCH 12/19] [LOGGING] Improved logging with block id associations --- cronjobs/pps_payout.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index 864e8b83..50fc5d80 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -169,35 +169,39 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { exit(1); } // Per account statistics - $log->logInfo("\tStarting to store fresh user statistics..."); + $log->logInfo("\tRefresh user statistics..."); if (!$aAccountShares = $share->getSharesForAccounts(@$iLastBlockShare, $aBlock['share_id'])) { $log->logError("Failed to Account Shares. ERROR: " . $share->getCronError()); } - foreach ($aAccountShares as $key => $aData) { if (!$statistics->updateShareStatistics($aData, $aBlock['id'])) $log->logError("Failed to update statistics for Block " . $aBlock['id'] . "for" . $aData['username'] . ' ERROR: ' . $statistics->getCronError()); } + $log->logInfo("\Statistics updated."); // Move shares to archive - $log->logInfo("\tMove shares to archive..."); + $log->logInfo("\t$aBlock['id']\t Move shares to archive..."); if ($aBlock['share_id'] < $iLastShareId) { if (!$share->moveArchive($aBlock['share_id'], $aBlock['id'], @$iLastBlockShare)) $log->logError("Failed to copy shares to from " . $aBlock['share_id'] . " to " . $iLastBlockShare . ' Error: ' . $share->getCronError()); } + $log->logInfo("\t$aBlock['id']\t Shares moved to archive..."); + // Delete shares - $log->logInfo("\tDelete accounted shares..."); + $log->logInfo("\t$aBlock['id']\t Deleting accounted shares..."); if ($aBlock['share_id'] < $iLastShareId && !$share->deleteAccountedShares($aBlock['share_id'], $iLastBlockShare)) { $log->logFatal("Failed to delete accounted shares from " . $aBlock['share_id'] . " to " . $iLastBlockShare . ", aborting! Error: " . $share->getCronError()); $monitoring->endCronjob($cron_name, 'E0016', 1, true); } + $log->logInfo("\t$aBlock['id']\t Deleted accounted shares."); + // Mark this block as accounted for - $log->logInfo("\tMarking Block as accounted..."); + $log->logInfo("\t$aBlock['id']\t Marking Block as accounted..."); if (!$block->setAccounted($aBlock['id'])) { $log->logFatal("Failed to mark block as accounted! Aborting! Error: " . $block->getCronError()); $monitoring->endCronjob($cron_name, 'E0014', 1, true); } - $log->logInfo("\tMarked Block" . $aBlock['id'] . " as accounted."); + $log->logInfo("\t$aBlock['id']\t Block paid and accounted for."); } $log->logInfo("Completed PPS Payout"); From 0972fa9a7cecc0d278c835951da5ddbd864cf8c9 Mon Sep 17 00:00:00 2001 From: Neozonz Date: Tue, 21 Jan 2014 22:03:14 -0500 Subject: [PATCH 13/19] [Improved] Logic --- cronjobs/pps_payout.php | 103 ++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index 50fc5d80..d8616a6b 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -148,60 +148,61 @@ if (!$setting->setValue('pps_last_share_id', $iLastShareId)) { // Fetch all unaccounted blocks $log->logInfo("\tFetching unaccounted blocks."); -if (!$aAllBlocks = $block->getAllUnaccounted('ASC')) { - $log->logInfo("Failed to fetch unaccounted Blocks. NOTICE: " . $block->getCronError()); -} -if (empty($aAllBlocks)) { - $log->logInfo("\tNo new blocks."); - // No monitoring event here, not fatal for PPS -} - -// Go through blocks and archive/delete shares that have been accounted for -foreach ($aAllBlocks as $iIndex => $aBlock) { - // If we are running through more than one block, check for previous share ID - $log->logInfo("\tProcess each block for Previous Share ID."); - $iLastBlockShare = @$aAllBlocks[$iIndex - 1]['share_id'] ? @$aAllBlocks[$iIndex - 1]['share_id'] : 0; - if (!is_numeric($aBlock['share_id'])) { - $log->logFatal("Block " . $aBlock['height'] . " has no share_id associated with it, not going to continue"); - $monitoring->setStatus($cron_name . "_active", "yesno", 0); - $monitoring->setStatus($cron_name . "_message", "message", "Block " . $aBlock['height'] . " has no share_id associated with it"); - $monitoring->setStatus($cron_name . "_status", "okerror", 1); - exit(1); - } - // Per account statistics - $log->logInfo("\tRefresh user statistics..."); - if (!$aAccountShares = $share->getSharesForAccounts(@$iLastBlockShare, $aBlock['share_id'])) { - $log->logError("Failed to Account Shares. ERROR: " . $share->getCronError()); - } - foreach ($aAccountShares as $key => $aData) { - if (!$statistics->updateShareStatistics($aData, $aBlock['id'])) - $log->logError("Failed to update statistics for Block " . $aBlock['id'] . "for" . $aData['username'] . ' ERROR: ' . $statistics->getCronError()); - } - $log->logInfo("\Statistics updated."); +if ($aAllBlocks = $block->getAllUnaccounted('ASC')) { + // Go through blocks and archive/delete shares that have been accounted for + foreach ($aAllBlocks as $iIndex => $aBlock) { + // If we are running through more than one block, check for previous share ID + $log->logInfo("\tProcess each block for Previous Share ID."); + $iLastBlockShare = @$aAllBlocks[$iIndex - 1]['share_id'] ? @$aAllBlocks[$iIndex - 1]['share_id'] : 0; + if (!is_numeric($aBlock['share_id'])) { + $log->logFatal("Block " . $aBlock['height'] . " has no share_id associated with it, not going to continue"); + $monitoring->setStatus($cron_name . "_active", "yesno", 0); + $monitoring->setStatus($cron_name . "_message", "message", "Block " . $aBlock['height'] . " has no share_id associated with it"); + $monitoring->setStatus($cron_name . "_status", "okerror", 1); + exit(1); + } + // Per account statistics + $log->logInfo("\tRefresh user statistics..."); + if (!$aAccountShares = $share->getSharesForAccounts(@$iLastBlockShare, $aBlock['share_id'])) { + $log->logError("Failed to Account Shares. ERROR: " . $share->getCronError()); + } + foreach ($aAccountShares as $key => $aData) { + if (!$statistics->updateShareStatistics($aData, $aBlock['id'])) + $log->logError("Failed to update statistics for Block " . $aBlock['id'] . "for" . $aData['username'] . ' ERROR: ' . $statistics->getCronError()); + } + $log->logInfo("\Statistics updated."); - // Move shares to archive - $log->logInfo("\t$aBlock['id']\t Move shares to archive..."); - if ($aBlock['share_id'] < $iLastShareId) { - if (!$share->moveArchive($aBlock['share_id'], $aBlock['id'], @$iLastBlockShare)) - $log->logError("Failed to copy shares to from " . $aBlock['share_id'] . " to " . $iLastBlockShare . ' Error: ' . $share->getCronError()); - } - $log->logInfo("\t$aBlock['id']\t Shares moved to archive..."); + // Move shares to archive + $log->logInfo("\t$aBlock['id']\t Move shares to archive..."); + if ($aBlock['share_id'] < $iLastShareId) { + if (!$share->moveArchive($aBlock['share_id'], $aBlock['id'], @$iLastBlockShare)) + $log->logError("Failed to copy shares to from " . $aBlock['share_id'] . " to " . $iLastBlockShare . ' Error: ' . $share->getCronError()); + } + $log->logInfo("\t$aBlock['id']\t Shares moved to archive..."); - // Delete shares - $log->logInfo("\t$aBlock['id']\t Deleting accounted shares..."); - if ($aBlock['share_id'] < $iLastShareId && !$share->deleteAccountedShares($aBlock['share_id'], $iLastBlockShare)) { - $log->logFatal("Failed to delete accounted shares from " . $aBlock['share_id'] . " to " . $iLastBlockShare . ", aborting! Error: " . $share->getCronError()); - $monitoring->endCronjob($cron_name, 'E0016', 1, true); - } - $log->logInfo("\t$aBlock['id']\t Deleted accounted shares."); + // Delete shares + $log->logInfo("\t$aBlock['id']\t Deleting accounted shares..."); + if ($aBlock['share_id'] < $iLastShareId && !$share->deleteAccountedShares($aBlock['share_id'], $iLastBlockShare)) { + $log->logFatal("Failed to delete accounted shares from " . $aBlock['share_id'] . " to " . $iLastBlockShare . ", aborting! Error: " . $share->getCronError()); + $monitoring->endCronjob($cron_name, 'E0016', 1, true); + } + $log->logInfo("\t$aBlock['id']\t Deleted accounted shares."); - // Mark this block as accounted for - $log->logInfo("\t$aBlock['id']\t Marking Block as accounted..."); - if (!$block->setAccounted($aBlock['id'])) { - $log->logFatal("Failed to mark block as accounted! Aborting! Error: " . $block->getCronError()); - $monitoring->endCronjob($cron_name, 'E0014', 1, true); - } - $log->logInfo("\t$aBlock['id']\t Block paid and accounted for."); + // Mark this block as accounted for + $log->logInfo("\t$aBlock['id']\t Marking Block as accounted..."); + if (!$block->setAccounted($aBlock['id'])) { + $log->logFatal("Failed to mark block as accounted! Aborting! Error: " . $block->getCronError()); + $monitoring->endCronjob($cron_name, 'E0014', 1, true); + } + $log->logInfo("\t$aBlock['id']\t Block paid and accounted for."); + } +} +else if (empty($aAllBlocks)) { + $log->logInfo("\tNo new blocks."); + // No monitoring event here, not fatal for PPS +} +else { + $log->logInfo("Failed to fetch unaccounted Blocks. NOTICE: " . $block->getCronError()); } $log->logInfo("Completed PPS Payout"); From d9723ba6b58f7b83098f678fefbf991129c5f5a6 Mon Sep 17 00:00:00 2001 From: Neozonz Date: Tue, 21 Jan 2014 22:46:51 -0500 Subject: [PATCH 14/19] [FIX] Tabbing [Improved] Wording [Improved] Logic of conditions --- cronjobs/pps_payout.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index d8616a6b..ab34f8e7 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -28,7 +28,7 @@ require_once('shared.inc.php'); // Check if we are set as the payout system if ($config['payout_system'] != 'pps') { - $log->logInfo("Please activate this cron in configuration via payout_system = pps\n"); + $log->logInfo("\tPlease activate this cron in configuration via payout_system = pps\n"); exit(0); } $log->logInfo("Starting PPS Payout..."); @@ -51,50 +51,50 @@ if ( $bitcoin->can_connect() === true ){ // We don't use the classes implementation just in case people start mucking around with it if ($config['pps']['reward']['type'] == 'blockavg' && $block->getBlockCount() > 0) { $pps_reward = round($block->getAvgBlockReward($config['pps']['blockavg']['blockcount'])); - $log->logInfo("PPS reward using block average, amount: " . $pps_reward . "\tdifficulty: " . $dDifficulty); + $log->logInfo("\tPPS reward using block average, amount: " . $pps_reward . "\tdifficulty: " . $dDifficulty); } else { if ($config['pps']['reward']['type'] == 'block') { if ($aLastBlock = $block->getLast()) { $pps_reward = $aLastBlock['amount']; - $log->logInfo("PPS value (Last Block): " . $pps_reward); + $log->logInfo("\tPPS value (Last Block): " . $pps_reward); } else { $pps_reward = $config['pps']['reward']['default']; - $log->logInfo("PPS value (Default): " . $pps_reward); + $log->logInfo("\tPPS value (Default): " . $pps_reward); } } else { $pps_reward = $config['pps']['reward']['default']; - $log->logInfo("PPS value (Default): " . $pps_reward); + $log->logInfo("\tPPS value (Default): " . $pps_reward); } } // Per-share value to be paid out to users $pps_value = round($pps_reward / (pow(2, $config['target_bits']) * $dDifficulty), 12); -$log->logInfo("PPS value: " . $pps_value); +$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->logInfo("PPS Last Share ID: " . $iPreviousShareId); +$log->logInfo("\tPPS Last Share ID: " . $iPreviousShareId); if (!$iLastShareId = $share->getLastInsertedShareId()) { $log->logError("Failed to fetch Last Inserted PPS Share ID. ERROR: " . $share->getCronError()); } -$log->logInfo("PPS Last Processed Share ID: " . $iLastShareId); +$log->logInfo("\tPPS Last Processed Share ID: " . $iLastShareId); // Check for all new shares, we start one higher as our last accounted share to avoid duplicates -$log->logInfo("Query getSharesForAccounts... starting..."); +$log->logInfo("\tQuery getSharesForAccounts... starting..."); if (!$aAccountShares = $share->getSharesForAccounts($iPreviousShareId + 1, $iLastShareId)) { $log->logError("Failed to fetch Account Shares. ERROR: " . $share->getCronError()); } -$log->logInfo("Query Completed..."); +$log->logInfo("\tQuery Completed..."); if (!empty($aAccountShares)) { // Info for this payout - $log->logInfo("PPS reward type: " . $config['pps']['reward']['type'] . ", amount: " . $pps_reward . "\tdifficulty: " . $dDifficulty . "\tPPS value: " . $pps_value); - $log->logInfo("Running through accounts to process shares..."); - $log->logInfo("ID\tUsername\tInvalid\tValid\t\tPPS Value\t\tPayout\t\tDonation\tFee"); + $log->logInfo("\tPPS reward type: " . $config['pps']['reward']['type'] . ", amount: " . $pps_reward . "\tdifficulty: " . $dDifficulty . "\tPPS value: " . $pps_value); + $log->logInfo("\tRunning through accounts to process shares..."); + $log->logInfo("\tID\tUsername\tInvalid\tValid\t\tPPS Value\t\tPayout\t\tDonation\tFee"); } foreach ($aAccountShares as $aData) { @@ -170,31 +170,31 @@ if ($aAllBlocks = $block->getAllUnaccounted('ASC')) { if (!$statistics->updateShareStatistics($aData, $aBlock['id'])) $log->logError("Failed to update statistics for Block " . $aBlock['id'] . "for" . $aData['username'] . ' ERROR: ' . $statistics->getCronError()); } - $log->logInfo("\Statistics updated."); + $log->logInfo("\t\Statistics updated."); // Move shares to archive - $log->logInfo("\t$aBlock['id']\t Move shares to archive..."); + $log->logInfo("\tBlock: " . $aBlock['id'] . "\t Move shares to archive..."); if ($aBlock['share_id'] < $iLastShareId) { if (!$share->moveArchive($aBlock['share_id'], $aBlock['id'], @$iLastBlockShare)) $log->logError("Failed to copy shares to from " . $aBlock['share_id'] . " to " . $iLastBlockShare . ' Error: ' . $share->getCronError()); } - $log->logInfo("\t$aBlock['id']\t Shares moved to archive..."); + $log->logInfo("\tBlock: " . $aBlock['id'] . "\t Shares moved to archive..."); // Delete shares - $log->logInfo("\t$aBlock['id']\t Deleting accounted shares..."); + $log->logInfo("\tBlock: " . $aBlock['id'] . "\t Deleting accounted shares..."); if ($aBlock['share_id'] < $iLastShareId && !$share->deleteAccountedShares($aBlock['share_id'], $iLastBlockShare)) { $log->logFatal("Failed to delete accounted shares from " . $aBlock['share_id'] . " to " . $iLastBlockShare . ", aborting! Error: " . $share->getCronError()); $monitoring->endCronjob($cron_name, 'E0016', 1, true); } - $log->logInfo("\t$aBlock['id']\t Deleted accounted shares."); + $log->logInfo("\tBlock: " . $aBlock['id'] . "\t Deleted accounted shares."); // Mark this block as accounted for - $log->logInfo("\t$aBlock['id']\t Marking Block as accounted..."); + $log->logInfo("\tBlock: " . $aBlock['id'] . "\t Marking Block as accounted..."); if (!$block->setAccounted($aBlock['id'])) { $log->logFatal("Failed to mark block as accounted! Aborting! Error: " . $block->getCronError()); $monitoring->endCronjob($cron_name, 'E0014', 1, true); } - $log->logInfo("\t$aBlock['id']\t Block paid and accounted for."); + $log->logInfo("\tBlock: " . $aBlock['id'] . "\t Block paid and accounted for."); } } else if (empty($aAllBlocks)) { From 9c2ce49e8e4af604d9884be1828a515efa9e1db7 Mon Sep 17 00:00:00 2001 From: Neozonz Date: Tue, 21 Jan 2014 22:48:12 -0500 Subject: [PATCH 15/19] [FIX] Tabbing [Improved] Wording [Improved] Logic of conditions --- cronjobs/payouts.php | 233 ++++++++++++++++++++++--------------------- 1 file changed, 118 insertions(+), 115 deletions(-) diff --git a/cronjobs/payouts.php b/cronjobs/payouts.php index 972a8cf6..136cd7b9 100755 --- a/cronjobs/payouts.php +++ b/cronjobs/payouts.php @@ -34,129 +34,132 @@ if ($bitcoin->can_connect() !== true) { $log->logFatal(" unable to connect to RPC server, exiting"); $monitoring->endCronjob($cron_name, 'E0006', 1, true); } - if ($setting->getValue('disable_manual_payouts') != 1) { - // Fetch outstanding payout requests - if (!$aPayouts = $oPayout->getUnprocessedPayouts()) { + // Fetch outstanding payout requests + if ($aPayouts = $oPayout->getUnprocessedPayouts()) { + if (count($aPayouts) > 0) { + $log->logInfo("\tStarting Manual Payments..."); + $log->logInfo("\tAccount ID\tUsername\tBalance\t\tCoin Address"); + foreach ($aPayouts as $aData) { + $aBalance = $transaction->getBalance($aData['account_id']); + $dBalance = $aBalance['confirmed']; + $aData['coin_address'] = $user->getCoinAddress($aData['account_id']); + $aData['username'] = $user->getUserName($aData['account_id']); + if ($dBalance > $config['txfee_manual']) { + // To ensure we don't run this transaction again, lets mark it completed + if (!$oPayout->setProcessed($aData['id'])) { + $log->logFatal('unable to mark transactions ' . $aData['id'] . ' as processed. ERROR: ' . $oPayout->getCronError()); + $monitoring->endCronjob($cron_name, 'E0010', 1, true); + } + $log->logInfo("\t" . $aData['account_id'] . "\t\t" . $aData['username'] . "\t" . $dBalance . "\t\t" . $aData['coin_address']); + try { + $txid = $bitcoin->sendtoaddress($aData['coin_address'], $dBalance - $config['txfee_manual']); + } catch (Exception $e) { + $log->logError('Skipping payment. Failed to send balance to coin address: ' . $aData['coin_address'] . ' ERROR: ' . $e->getMessage()); + continue; + } + if ($transaction->addTransaction($aData['account_id'], $dBalance - $config['txfee_manual'], 'Debit_MP', NULL, $aData['coin_address'], $txid) && $transaction->addTransaction($aData['account_id'], $config['txfee_manual'], 'TXFee', NULL, $aData['coin_address'])) { + // Mark all older transactions as archived + if (!$transaction->setArchived($aData['account_id'], $transaction->insert_id)) + $log->logError('Failed to mark transactions for #' . $aData['account_id'] . ' prior to #' . $transaction->insert_id . ' as archived. ERROR: ' . $transaction->getCronError()); + // Notify user via mail + $aMailData['email'] = $user->getUserEmail($user->getUserName($aData['account_id'])); + $aMailData['subject'] = 'Manual Payout Completed'; + $aMailData['amount'] = $dBalance - $config['txfee_manual']; + $aMailData['payout_id'] = $aData['id']; + if (!$notification->sendNotification($aData['account_id'], 'manual_payout', $aMailData)) + $log->logError('Failed to send notification email to users address: ' . $aMailData['email'] . 'ERROR: ' . $notification->getCronError()); + // Recheck the users balance to make sure it is now 0 + if (!$aBalance = $transaction->getBalance($aData['account_id'])) { + $log->logFatal('Failed to fetch balance for account ' . $aData['account_id'] . '. ERROR: ' . $transaction->getCronError()); + $monitoring->endCronjob($cron_name, 'E0065', 1, true); + } + if ($aBalance['confirmed'] > 0) { + $log->logFatal('User has a remaining balance of ' . $aBalance['confirmed'] . ' after a successful payout!'); + $monitoring->endCronjob($cron_name, 'E0065', 1, true); + } + } + else { + $log->logFatal('Failed to add new Debit_MP transaction in database for user ' . $user->getUserName($aData['account_id']) . ' ERROR: ' . $transaction->getCronError()); + $monitoring->endCronjob($cron_name, 'E0064', 1, true); + } + } + + } + } + } + else if (empty($aPayouts)) { + $log->logInfo("\tNo new manual payout requests."); + } +else { $log->logFatal("\tFailed Processing Manual Payment Queue..."); $monitoring->endCronjob($cron_name, 'E0050', 1, true); - } - - if (count($aPayouts > 0)) $log->logDebug(" found " . count($aPayouts) . " queued manual payout requests"); - - if (count($aPayouts) > 0) { - $log->logInfo("\tStarting Manual Payments..."); - $log->logInfo("\tAccount ID\tUsername\tBalance\t\tCoin Address"); - foreach ($aPayouts as $aData) { - $aBalance = $transaction->getBalance($aData['account_id']); - $dBalance = $aBalance['confirmed']; - $aData['coin_address'] = $user->getCoinAddress($aData['account_id']); - $aData['username'] = $user->getUserName($aData['account_id']); - if ($dBalance > $config['txfee_manual']) { - // To ensure we don't run this transaction again, lets mark it completed - if (!$oPayout->setProcessed($aData['id'])) { - $log->logFatal('unable to mark transactions ' . $aData['id'] . ' as processed. ERROR: ' . $oPayout->getCronError()); - $monitoring->endCronjob($cron_name, 'E0010', 1, true); - } - - $log->logInfo("\t" . $aData['account_id'] . "\t\t" . $aData['username'] . "\t" . $dBalance . "\t\t" . $aData['coin_address']); - try { - $txid = $bitcoin->sendtoaddress($aData['coin_address'], $dBalance - $config['txfee_manual']); - } catch (Exception $e) { - $log->logError('Skipping payment. Failed to send balance to coin address: ' . $aData['coin_address'] . ' ERROR: ' . $e->getMessage()); - continue; - } - - if ($transaction->addTransaction($aData['account_id'], $dBalance - $config['txfee_manual'], 'Debit_MP', NULL, $aData['coin_address'], $txid) && $transaction->addTransaction($aData['account_id'], $config['txfee_manual'], 'TXFee', NULL, $aData['coin_address'])) { - // Mark all older transactions as archived - if (!$transaction->setArchived($aData['account_id'], $transaction->insert_id)) - $log->logError('Failed to mark transactions for #' . $aData['account_id'] . ' prior to #' . $transaction->insert_id . ' as archived. ERROR: ' . $transaction->getCronError()); - // Notify user via mail - $aMailData['email'] = $user->getUserEmail($user->getUserName($aData['account_id'])); - $aMailData['subject'] = 'Manual Payout Completed'; - $aMailData['amount'] = $dBalance - $config['txfee_manual']; - $aMailData['payout_id'] = $aData['id']; - if (!$notification->sendNotification($aData['account_id'], 'manual_payout', $aMailData)) - $log->logError('Failed to send notification email to users address: ' . $aMailData['email'] . 'ERROR: ' . $notification->getCronError()); - // Recheck the users balance to make sure it is now 0 - if (!$aBalance = $transaction->getBalance($aData['account_id'])) { - $log->logFatal('Failed to fetch balance for account ' . $aData['account_id'] . '. ERROR: ' . $transaction->getCronError()); - $monitoring->endCronjob($cron_name, 'E0065', 1, true); - } - if ($aBalance['confirmed'] > 0) { - $log->logFatal('User has a remaining balance of ' . $aBalance['confirmed'] . ' after a successful payout!'); - $monitoring->endCronjob($cron_name, 'E0065', 1, true); - } - } else { - $log->logFatal('Failed to add new Debit_MP transaction in database for user ' . $user->getUserName($aData['account_id']) . ' ERROR: ' . $transaction->getCronError()); - $monitoring->endCronjob($cron_name, 'E0064', 1, true); - } - } - - } - } -} else { - $log->logDebug("Manual payouts are disabled via admin panel"); } - +if (count($aPayouts > 0)) $log->logDebug(" found " . count($aPayouts) . " queued manual payout requests"); +} +else { + $log->logDebug("Manual payouts are disabled via admin panel"); +} if ($setting->getValue('disable_auto_payouts') != 1) { - // Fetch all users balances - if (!$users = $transaction->getAPQueue()) { - $log->logFatal("\tFailed Processing Auto Payment Payment Queue. ERROR: " . $transaction->getCronError()); - $monitoring->endCronjob($cron_name, 'E0050', 1, true); - } - if (count($users) > 0) $log->logDebug(" found " . count($users) . " queued payout(s)"); - - // Go through users and run transactions - if (! empty($users)) { - $log->logInfo("\tStarting Auto Payments..."); - $log->logInfo("\tUserID\tUsername\tBalance\tThreshold\tAddress"); - - foreach ($users as $aUserData) { - $dBalance = $aUserData['confirmed']; - $log->logInfo("\t" . $aUserData['id'] . "\t" . $aUserData['username'] . "\t" . $dBalance . "\t" . $aUserData['ap_threshold'] . "\t\t" . $aUserData['coin_address']); - - // Only run if balance meets threshold and can pay the potential transaction fee - if ($dBalance > $aUserData['ap_threshold'] && $dBalance > $config['txfee_auto']) { - // Send balance, fees are reduced later by RPC Server - try { - $txid = $bitcoin->sendtoaddress($aUserData['coin_address'], $dBalance - $config['txfee_auto']); - } catch (Exception $e) { - $log->logError('Skipping payment. Failed to send balance to coin address: ' . $aData['coin_address'] . ' ERROR: ' . $e->getMessage()); - continue; - } - - // Create transaction record - if ($transaction->addTransaction($aUserData['id'], $dBalance - $config['txfee_auto'], 'Debit_AP', NULL, $aUserData['coin_address'], $txid) && $transaction->addTransaction($aUserData['id'], $config['txfee_auto'], 'TXFee', NULL, $aUserData['coin_address'])) { - // Mark all older transactions as archived - if (!$transaction->setArchived($aUserData['id'], $transaction->insert_id)) - $log->logError('Failed to mark transactions for user #' . $aUserData['id'] . ' prior to #' . $transaction->insert_id . ' as archived. ERROR: ' . $transaction->getCronError()); - // Notify user via mail - $aMailData['email'] = $user->getUserEmail($user->getUserName($aUserData['id'])); - $aMailData['subject'] = 'Auto Payout Completed'; - $aMailData['amount'] = $dBalance - $config['txfee_auto']; - if (!$notification->sendNotification($aUserData['id'], 'auto_payout', $aMailData)) - $log->logError('Failed to send notification email to users address: ' . $aMailData['email'] . ' ERROR: ' . $notification->getCronError()); - // Recheck the users balance to make sure it is now 0 - $aBalance = $transaction->getBalance($aUserData['id']); - if ($aBalance['confirmed'] > 0) { - $log->logFatal('User has a remaining balance of ' . $aBalance['confirmed'] . ' after a successful payout!'); - $monitoring->endCronjob($cron_name, 'E0065', 1, true); - } - } else { - $log->logFatal('Failed to add new Debit_AP transaction in database for user ' . $user->getUserName($aUserData['id']) . ' ERROR: ' . $transaction->getCronError()); - $monitoring->endCronjob($cron_name, 'E0064', 1, true); - } - } + // Fetch all users balances + if (!$users = $transaction->getAPQueue()) { + if (!empty($users)) { + if (count($users) > 0) $log->logDebug(" found " . count($users) . " queued payout(s)"); + // Go through users and run transactions + $log->logInfo("\tStarting Auto Payments..."); + $log->logInfo("\tUserID\tUsername\tBalance\tThreshold\tAddress"); + foreach ($users as $aUserData) { + $dBalance = $aUserData['confirmed']; + $log->logInfo("\t" . $aUserData['id'] . "\t" . $aUserData['username'] . "\t" . $dBalance . "\t" . $aUserData['ap_threshold'] . "\t\t" . $aUserData['coin_address']); + // Only run if balance meets threshold and can pay the potential transaction fee + if ($dBalance > $aUserData['ap_threshold'] && $dBalance > $config['txfee_auto']) { + // Send balance, fees are reduced later by RPC Server + try { + $txid = $bitcoin->sendtoaddress($aUserData['coin_address'], $dBalance - $config['txfee_auto']); + } + catch (Exception $e) { + $log->logError('Skipping payment. Failed to send balance to coin address: ' . $aData['coin_address'] . ' ERROR: ' . $e->getMessage()); + continue; + } + // Create transaction record + if ($transaction->addTransaction($aUserData['id'], $dBalance - $config['txfee_auto'], 'Debit_AP', NULL, $aUserData['coin_address'], $txid) && $transaction->addTransaction($aUserData['id'], $config['txfee_auto'], 'TXFee', NULL, $aUserData['coin_address'])) { + // Mark all older transactions as archived + if (!$transaction->setArchived($aUserData['id'], $transaction->insert_id)) + $log->logError('Failed to mark transactions for user #' . $aUserData['id'] . ' prior to #' . $transaction->insert_id . ' as archived. ERROR: ' . $transaction->getCronError()); + // Notify user via mail + $aMailData['email'] = $user->getUserEmail($user->getUserName($aUserData['id'])); + $aMailData['subject'] = 'Auto Payout Completed'; + $aMailData['amount'] = $dBalance - $config['txfee_auto']; + if (!$notification->sendNotification($aUserData['id'], 'auto_payout', $aMailData)) + $log->logError('Failed to send notification email to users address: ' . $aMailData['email'] . ' ERROR: ' . $notification->getCronError()); + // Recheck the users balance to make sure it is now 0 + $aBalance = $transaction->getBalance($aUserData['id']); + if ($aBalance['confirmed'] > 0) { + $log->logFatal('User has a remaining balance of ' . $aBalance['confirmed'] . ' after a successful payout!'); + $monitoring->endCronjob($cron_name, 'E0065', 1, true); + } + } + else { + $log->logFatal('Failed to add new Debit_AP transaction in database for user ' . $user->getUserName($aUserData['id']) . ' ERROR: ' . $transaction->getCronError()); + $monitoring->endCronjob($cron_name, 'E0064', 1, true); + } + } + } + } } - } else { - $log->logDebug("Users have not configured their AP > 0"); - } -} else { - $log->logDebug("Auto payouts disabled via admin panel"); + else if(empty($users)) { + $log->logInfo("\tNo Auto payments eligible."); + $log->logDebug("Users have not configured their AP > 0"); + } + else{ + $log->logFatal("\tFailed Processing Auto Payment Payment Queue. ERROR: " . $transaction->getCronError()); + $monitoring->endCronjob($cron_name, 'E0050', 1, true); + } +} +else { + $log->logDebug("Auto payouts disabled via admin panel"); } $log->logInfo("\tCompleted Payouts"); - // Cron cleanup and monitoring require_once('cron_end.inc.php'); ?> From f165eed8410a000d9dd6164d7dff2ce6002d4cff Mon Sep 17 00:00:00 2001 From: Neozonz Date: Tue, 21 Jan 2014 22:56:04 -0500 Subject: [PATCH 16/19] [Improved] Wording --- cronjobs/payouts.php | 9 +++++---- cronjobs/pps_payout.php | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cronjobs/payouts.php b/cronjobs/payouts.php index 136cd7b9..95bbbdd6 100755 --- a/cronjobs/payouts.php +++ b/cronjobs/payouts.php @@ -36,6 +36,7 @@ if ($bitcoin->can_connect() !== true) { } if ($setting->getValue('disable_manual_payouts') != 1) { // Fetch outstanding payout requests + $log->logInfo("\tStarting Payments..."); if ($aPayouts = $oPayout->getUnprocessedPayouts()) { if (count($aPayouts) > 0) { $log->logInfo("\tStarting Manual Payments..."); @@ -89,10 +90,10 @@ if ($setting->getValue('disable_manual_payouts') != 1) { } } else if (empty($aPayouts)) { - $log->logInfo("\tNo new manual payout requests."); + $log->logInfo("\tStopping Payments. No Payout Requests Found."); } else { - $log->logFatal("\tFailed Processing Manual Payment Queue..."); + $log->logFatal("\tFailed Processing Manual Payment Queue...Aborting..."); $monitoring->endCronjob($cron_name, 'E0050', 1, true); } if (count($aPayouts > 0)) $log->logDebug(" found " . count($aPayouts) . " queued manual payout requests"); @@ -102,7 +103,7 @@ else { } if ($setting->getValue('disable_auto_payouts') != 1) { // Fetch all users balances - if (!$users = $transaction->getAPQueue()) { + if ($users = $transaction->getAPQueue()) { if (!empty($users)) { if (count($users) > 0) $log->logDebug(" found " . count($users) . " queued payout(s)"); // Go through users and run transactions @@ -148,7 +149,7 @@ if ($setting->getValue('disable_auto_payouts') != 1) { } } else if(empty($users)) { - $log->logInfo("\tNo Auto payments eligible."); + $log->logInfo("\tSkipped payments. No auto payments eligible."); $log->logDebug("Users have not configured their AP > 0"); } else{ diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index ab34f8e7..52195a8c 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -170,7 +170,7 @@ if ($aAllBlocks = $block->getAllUnaccounted('ASC')) { if (!$statistics->updateShareStatistics($aData, $aBlock['id'])) $log->logError("Failed to update statistics for Block " . $aBlock['id'] . "for" . $aData['username'] . ' ERROR: ' . $statistics->getCronError()); } - $log->logInfo("\t\Statistics updated."); + $log->logInfo("\tUser Statistics updated."); // Move shares to archive $log->logInfo("\tBlock: " . $aBlock['id'] . "\t Move shares to archive..."); From b93599211c9682f8443a740a9f1854a3235ee9f2 Mon Sep 17 00:00:00 2001 From: Neozonz Date: Tue, 21 Jan 2014 22:59:24 -0500 Subject: [PATCH 17/19] [Improve] Wording --- cronjobs/payouts.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cronjobs/payouts.php b/cronjobs/payouts.php index 95bbbdd6..d17b71c5 100755 --- a/cronjobs/payouts.php +++ b/cronjobs/payouts.php @@ -107,7 +107,7 @@ if ($setting->getValue('disable_auto_payouts') != 1) { if (!empty($users)) { if (count($users) > 0) $log->logDebug(" found " . count($users) . " queued payout(s)"); // Go through users and run transactions - $log->logInfo("\tStarting Auto Payments..."); + $log->logInfo("Starting Payments..."); $log->logInfo("\tUserID\tUsername\tBalance\tThreshold\tAddress"); foreach ($users as $aUserData) { $dBalance = $aUserData['confirmed']; @@ -149,7 +149,7 @@ if ($setting->getValue('disable_auto_payouts') != 1) { } } else if(empty($users)) { - $log->logInfo("\tSkipped payments. No auto payments eligible."); + $log->logInfo("\tSkipping payments. No auto payments eligible."); $log->logDebug("Users have not configured their AP > 0"); } else{ From 09cf8df09a0406d9eec074aa0355859a47e1e14f Mon Sep 17 00:00:00 2001 From: Neozonz Date: Tue, 21 Jan 2014 23:00:28 -0500 Subject: [PATCH 18/19] [Improved] Look --- cronjobs/payouts.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cronjobs/payouts.php b/cronjobs/payouts.php index d17b71c5..5ed500a0 100755 --- a/cronjobs/payouts.php +++ b/cronjobs/payouts.php @@ -36,7 +36,6 @@ if ($bitcoin->can_connect() !== true) { } if ($setting->getValue('disable_manual_payouts') != 1) { // Fetch outstanding payout requests - $log->logInfo("\tStarting Payments..."); if ($aPayouts = $oPayout->getUnprocessedPayouts()) { if (count($aPayouts) > 0) { $log->logInfo("\tStarting Manual Payments..."); @@ -160,7 +159,7 @@ if ($setting->getValue('disable_auto_payouts') != 1) { else { $log->logDebug("Auto payouts disabled via admin panel"); } -$log->logInfo("\tCompleted Payouts"); +$log->logInfo("Completed Payouts"); // Cron cleanup and monitoring require_once('cron_end.inc.php'); ?> From ba8f4f643d8477454017780a6f1c7f9f84ce3ca5 Mon Sep 17 00:00:00 2001 From: Neozonz Date: Tue, 21 Jan 2014 23:02:05 -0500 Subject: [PATCH 19/19] [Look] Finally statisfied ;) --- cronjobs/payouts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cronjobs/payouts.php b/cronjobs/payouts.php index 5ed500a0..88018fdf 100755 --- a/cronjobs/payouts.php +++ b/cronjobs/payouts.php @@ -148,7 +148,7 @@ if ($setting->getValue('disable_auto_payouts') != 1) { } } else if(empty($users)) { - $log->logInfo("\tSkipping payments. No auto payments eligible."); + $log->logInfo("\tSkipping payments. No Auto Payments Eligible."); $log->logDebug("Users have not configured their AP > 0"); } else{