From c1290d532741b7655d0ccb59a1d069bba471220d Mon Sep 17 00:00:00 2001 From: Huseyin Uslu Date: Tue, 18 Feb 2014 11:29:31 +0200 Subject: [PATCH 01/16] added block validation and account validation scripts --- scripts/validate_blocks.php | 34 ++++++++++++++++++++++ scripts/validate_users.php | 56 +++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 scripts/validate_blocks.php create mode 100644 scripts/validate_users.php diff --git a/scripts/validate_blocks.php b/scripts/validate_blocks.php new file mode 100644 index 00000000..f9b40b30 --- /dev/null +++ b/scripts/validate_blocks.php @@ -0,0 +1,34 @@ +#!/usr/bin/php +can_connect() !== true ) + die("Failed to connect to RPC server\n"); + + echo "Validating blocks in database against coind..\n"; + + // fetch all blocks + $allBlocks = $block->getAll(); + foreach ($allBlocks as $block) + { + try { + $blockInfo = $bitcoin->getblock($block['blockhash']); + } + catch(Exception $e) + { + // don't report orphan blocks. + if($block['confirmations']!= -1 && $e->getMessage() == 'RPC call did not return 200: HTTP error: 500 - JSON Response: [-5] Block not found') + { + echo "Block not found: database-id: $block[id] - height: $block[height].\n"; + } + } + } + + echo "Done..\n"; +?> \ No newline at end of file diff --git a/scripts/validate_users.php b/scripts/validate_users.php new file mode 100644 index 00000000..e188b28f --- /dev/null +++ b/scripts/validate_users.php @@ -0,0 +1,56 @@ +#!/usr/bin/php +getAllAssoc(); + + $mask = "| %6s | %20s | %16s | %10s | %-12.12s | %5s | %5s | %12s | %5s | \n"; + printf($mask, 'ID', 'Username', 'LoggedIP', 'Last Login','Days Since', 'Ever', 'Trans', 'Balance','Stale'); + + $currentTime = time(); + $totalSavings = 0; + + foreach ($users as $user) + { + $id = $user['id']; + $isAdmin = $user['is_admin']; + $username = $user['username']; + $loggedIp = $user['loggedIp']; + $lastLogin = $user['last_login']; + $coinAddress = $user['coin_address']; + + $everLoggedIn = !empty($lastLogin); + $timeDelta = $currentTime - $lastLogin; + $lastLoginInDays = abs($timeDelta)/60/60/24; + + if($lastLoginInDays < $timeLimitInDays) + continue; + + // get transactions summary for the user + $summary = $transaction->getTransactionSummary($id); + $transactions_exists = !empty($summary); + + // get balances + $balances = $transaction->getBalance($id); + $confirmedBalance = $balances['confirmed']; + $totalSavings += $confirmedBalance; + + $staleAccount = $everLoggedIn == false && $transactions_exists == false; + + printf($mask, $id, $username, + $loggedIp, $lastLogin, $lastLoginInDays, $everLoggedIn ? 'yes' : 'no', + $transactions_exists ? 'yes' : 'no', $confirmedBalance, + $staleAccount ? 'yes' : 'no' ); + } + + echo "Total balance of stale accounts: $totalSavings \n"; +?> \ No newline at end of file From 981d73f988b363fed94c98aa90bd74c0cbc1deba Mon Sep 17 00:00:00 2001 From: Huseyin Uslu Date: Tue, 18 Feb 2014 13:00:47 +0200 Subject: [PATCH 02/16] applied seraphers proposed fixes & suggestions --- scripts/validate_blocks.php | 24 ++++++++++++++++++++---- scripts/validate_users.php | 8 ++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/scripts/validate_blocks.php b/scripts/validate_blocks.php index f9b40b30..c26b0428 100644 --- a/scripts/validate_blocks.php +++ b/scripts/validate_blocks.php @@ -6,27 +6,43 @@ chdir(dirname(__FILE__)); // Include all settings and classes - require_once('shared.inc.php'); + require_once('shared.inc.php'); if ( $bitcoin->can_connect() !== true ) die("Failed to connect to RPC server\n"); echo "Validating blocks in database against coind..\n"; + + $mask = "| %6s | %8s | %13s | %20s | %10s | \n"; + printf($mask, 'DB-ID', 'Height', 'Confirmations', 'Time', 'Status'); // fetch all blocks $allBlocks = $block->getAll(); foreach ($allBlocks as $block) { + //print_r($block); + $status = 'VALID'; + try { $blockInfo = $bitcoin->getblock($block['blockhash']); } catch(Exception $e) { - // don't report orphan blocks. - if($block['confirmations']!= -1 && $e->getMessage() == 'RPC call did not return 200: HTTP error: 500 - JSON Response: [-5] Block not found') + if($block['confirmations']== -1) { - echo "Block not found: database-id: $block[id] - height: $block[height].\n"; + $status = 'ORPHAN'; + } + else if($e->getMessage() == 'RPC call did not return 200: HTTP error: 500 - JSON Response: [-5] Block not found') + { + $status = 'INVALID'; } + else + { + $status = 'UNKNOWN'; + } + } + finally { + printf($mask, $block['id'], $block['height'], $block['confirmations'], strftime("%Y-%m-%d %H:%M:%S", $block['time']), $status); } } diff --git a/scripts/validate_users.php b/scripts/validate_users.php index e188b28f..e22bc6c6 100644 --- a/scripts/validate_users.php +++ b/scripts/validate_users.php @@ -13,7 +13,7 @@ // Fetch all users $users = $user->getAllAssoc(); - $mask = "| %6s | %20s | %16s | %10s | %-12.12s | %5s | %5s | %12s | %5s | \n"; + $mask = "| %6s | %20s | %16s | %20s | %12.12s | %5s | %5s | %12s | %5s | \n"; printf($mask, 'ID', 'Username', 'LoggedIP', 'Last Login','Days Since', 'Ever', 'Trans', 'Balance','Stale'); $currentTime = time(); @@ -30,7 +30,7 @@ $everLoggedIn = !empty($lastLogin); $timeDelta = $currentTime - $lastLogin; - $lastLoginInDays = abs($timeDelta)/60/60/24; + $lastLoginInDays = round(abs($timeDelta)/60/60/24, 0); if($lastLoginInDays < $timeLimitInDays) continue; @@ -47,8 +47,8 @@ $staleAccount = $everLoggedIn == false && $transactions_exists == false; printf($mask, $id, $username, - $loggedIp, $lastLogin, $lastLoginInDays, $everLoggedIn ? 'yes' : 'no', - $transactions_exists ? 'yes' : 'no', $confirmedBalance, + $loggedIp, strftime("%Y-%m-%d %H:%M:%S", $lastLogin), $lastLoginInDays, $everLoggedIn ? 'yes' : 'no', + $transactions_exists ? 'yes' : 'no', round($confirmedBalance,8), $staleAccount ? 'yes' : 'no' ); } From cf4e2e2f6a58ad6a64cc0ebd38bc095efca07880 Mon Sep 17 00:00:00 2001 From: Huseyin Uslu Date: Tue, 18 Feb 2014 13:04:18 +0200 Subject: [PATCH 03/16] fixed newlines --- scripts/validate_blocks.php | 6 +++--- scripts/validate_users.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/validate_blocks.php b/scripts/validate_blocks.php index c26b0428..e7118021 100644 --- a/scripts/validate_blocks.php +++ b/scripts/validate_blocks.php @@ -9,9 +9,9 @@ require_once('shared.inc.php'); if ( $bitcoin->can_connect() !== true ) - die("Failed to connect to RPC server\n"); + die("Failed to connect to RPC server". PHP_EOL); - echo "Validating blocks in database against coind..\n"; + echo "Validating blocks in database against coind..". PHP_EOL; $mask = "| %6s | %8s | %13s | %20s | %10s | \n"; printf($mask, 'DB-ID', 'Height', 'Confirmations', 'Time', 'Status'); @@ -46,5 +46,5 @@ } } - echo "Done..\n"; + echo "Done..". PHP_EOL; ?> \ No newline at end of file diff --git a/scripts/validate_users.php b/scripts/validate_users.php index e22bc6c6..bc44971c 100644 --- a/scripts/validate_users.php +++ b/scripts/validate_users.php @@ -52,5 +52,5 @@ $staleAccount ? 'yes' : 'no' ); } - echo "Total balance of stale accounts: $totalSavings \n"; + echo "Total balance of stale accounts: $totalSavings" . PHP_EOL; ?> \ No newline at end of file From 347a43601dd923719e952fd78775405439cec0f9 Mon Sep 17 00:00:00 2001 From: Huseyin Uslu Date: Tue, 18 Feb 2014 13:08:15 +0200 Subject: [PATCH 04/16] removed a debug line --- scripts/validate_blocks.php | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/validate_blocks.php b/scripts/validate_blocks.php index e7118021..57895295 100644 --- a/scripts/validate_blocks.php +++ b/scripts/validate_blocks.php @@ -20,7 +20,6 @@ $allBlocks = $block->getAll(); foreach ($allBlocks as $block) { - //print_r($block); $status = 'VALID'; try { From f6ceace3868d83099824a30bfa9b3c8678e838d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20Uslu?= Date: Fri, 28 Feb 2014 23:40:08 +0200 Subject: [PATCH 05/16] fixed orphan detection --- scripts/validate_blocks.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/validate_blocks.php b/scripts/validate_blocks.php index 57895295..e1d0af9f 100644 --- a/scripts/validate_blocks.php +++ b/scripts/validate_blocks.php @@ -13,25 +13,25 @@ echo "Validating blocks in database against coind..". PHP_EOL; - $mask = "| %6s | %8s | %13s | %20s | %10s | \n"; + $mask = "| %6s | %8s | %13s | %20s | %10s |". PHP_EOL;; printf($mask, 'DB-ID', 'Height', 'Confirmations', 'Time', 'Status'); // fetch all blocks $allBlocks = $block->getAll(); foreach ($allBlocks as $block) - { - $status = 'VALID'; - + { try { - $blockInfo = $bitcoin->getblock($block['blockhash']); + if($block['confirmations']== -1) // mark orphan blocks. + $status = 'ORPHAN'; + else + { + $blockInfo = $bitcoin->getblock($block['blockhash']); + $status = 'VALID'; // if the getblock() call didn't throw an exception, it's a valid block then. + } } catch(Exception $e) { - if($block['confirmations']== -1) - { - $status = 'ORPHAN'; - } - else if($e->getMessage() == 'RPC call did not return 200: HTTP error: 500 - JSON Response: [-5] Block not found') + if($e->getMessage() == 'RPC call did not return 200: HTTP error: 500 - JSON Response: [-5] Block not found') { $status = 'INVALID'; } From 639d4ccb101e356213806d2d167fd993b1e73e2f Mon Sep 17 00:00:00 2001 From: rog1121 Date: Sat, 1 Mar 2014 17:00:51 -0700 Subject: [PATCH 06/16] Fix Notifications Class --- public/include/classes/notification.class.php | 2 +- public/include/pages/account/notifications.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 public/include/classes/notification.class.php mode change 100644 => 100755 public/include/pages/account/notifications.inc.php diff --git a/public/include/classes/notification.class.php b/public/include/classes/notification.class.php old mode 100644 new mode 100755 index d4376005..41aa1d92 --- a/public/include/classes/notification.class.php +++ b/public/include/classes/notification.class.php @@ -58,7 +58,7 @@ class Notification extends Mail { * @param id int Account ID * @return array Notification data **/ - public function getNofifications($account_id) { + public function getNotifications($account_id) { $this->debug->append("STA " . __METHOD__, 4); $stmt = $this->mysqli->prepare("SELECT * FROM $this->table WHERE account_id = ? ORDER BY time DESC"); if ($stmt && $stmt->bind_param('i', $account_id) && $stmt->execute() && $result = $stmt->get_result()) diff --git a/public/include/pages/account/notifications.inc.php b/public/include/pages/account/notifications.inc.php old mode 100644 new mode 100755 index 09d6b911..5fbf0355 --- a/public/include/pages/account/notifications.inc.php +++ b/public/include/pages/account/notifications.inc.php @@ -19,7 +19,7 @@ if ($user->isAuthenticated()) { } // Fetch notifications - $aNotifications = $notification->getNofifications($_SESSION['USERDATA']['id']); + $aNotifications = $notification->getNotifications($_SESSION['USERDATA']['id']); if (!$aNotifications) $_SESSION['POPUP'][] = array('CONTENT' => 'Could not find any notifications', 'TYPE' => 'errormsg'); // Fetch global settings From e8a72c877c6779c2a538fe423845387e002be5b9 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sun, 2 Mar 2014 11:44:37 +0100 Subject: [PATCH 07/16] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0238b3ff..4fdbff00 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ These people have supported this project with a donation: * [PCFiL](https://github.com/PCFiL) * [rog1121](https://github.com/rog1121)(https://rapidhash.net) * [Wow, Much Pool](http://www.wowmuchpool.com/) +* webxassDE (https://www.suchcoins.com/) Pools running MPOS ================== From 58807e580b8cf4706a2b291d7156fe29556d2f5e Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sun, 2 Mar 2014 12:33:40 +0100 Subject: [PATCH 08/16] [FIX] PHP Notice on Admin Settings page --- public/include/config/admin_settings.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/public/include/config/admin_settings.inc.php b/public/include/config/admin_settings.inc.php index eeb7d035..593d03b8 100644 --- a/public/include/config/admin_settings.inc.php +++ b/public/include/config/admin_settings.inc.php @@ -406,6 +406,7 @@ $aSettings['monitoring'][] = array( ); $aSettings['notifications'][] = array( 'display' => 'Notification Cleanup Time', 'type' => 'text', + 'size' => 10, 'default' => 7, 'name' => 'notifications_cleanup_time', 'value' => $setting->getValue('notifications_cleanup_time'), 'tooltip' => 'Maximum age in days of notifications before cleaned from database.' From 6fd55536fae0739aa9b4bbcd5ab605bb23a7a5f2 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sun, 2 Mar 2014 16:26:31 +0100 Subject: [PATCH 09/16] [FIX] Removed method call on PPS globals --- public/include/smarty_globals.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index b85fbbf2..61d350f4 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -137,6 +137,7 @@ if (@$_SESSION['USERDATA']['id']) { $aGlobal['userdata']['rawhashrate'] = $aUserMiningStats['hashrate']; $aGlobal['userdata']['hashrate'] = $aGlobal['userdata']['rawhashrate'] * $dPersonalHashrateModifier; $aGlobal['userdata']['sharerate'] = $aUserMiningStats['sharerate']; + $aGlobal['userdata']['sharedifficulty'] = $aUserMiningStats['avgsharediff']; switch ($config['payout_system']) { case 'prop': @@ -158,7 +159,6 @@ if (@$_SESSION['USERDATA']['id']) { $aGlobal['userdata']['pps']['unpaidshares'] = $statistics->getUserUnpaidPPSShares($_SESSION['USERDATA']['username'], $_SESSION['USERDATA']['id'], $setting->getValue('pps_last_share_id')); $aGlobal['ppsvalue'] = number_format($statistics->getPPSValue(), 12); $aGlobal['poolppsvalue'] = $aGlobal['ppsvalue'] * pow(2, $config['difficulty'] - 16); - $aGlobal['userdata']['sharedifficulty'] = $statistics->getUserShareDifficulty($_SESSION['USERDATA']['username'], $_SESSION['USERDATA']['id']); $aGlobal['userdata']['estimates'] = $statistics->getUserEstimates($aGlobal['userdata']['sharerate'], $aGlobal['userdata']['sharedifficulty'], $aGlobal['userdata']['donate_percent'], $aGlobal['userdata']['no_fees'], $aGlobal['ppsvalue']); break; } From e73adc193ed5fba02d4ddad86d77d293f0a764e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20Uslu?= Date: Sun, 2 Mar 2014 17:48:33 +0200 Subject: [PATCH 10/16] removed finally block --- scripts/validate_blocks.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/validate_blocks.php b/scripts/validate_blocks.php index e1d0af9f..eed93e43 100644 --- a/scripts/validate_blocks.php +++ b/scripts/validate_blocks.php @@ -40,9 +40,8 @@ $status = 'UNKNOWN'; } } - finally { - printf($mask, $block['id'], $block['height'], $block['confirmations'], strftime("%Y-%m-%d %H:%M:%S", $block['time']), $status); - } + + printf($mask, $block['id'], $block['height'], $block['confirmations'], strftime("%Y-%m-%d %H:%M:%S", $block['time']), $status); } echo "Done..". PHP_EOL; From 5bfa6c8db15bcfa942a60c0f0f789cbceb2631f8 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sun, 2 Mar 2014 16:58:45 +0100 Subject: [PATCH 11/16] [FIX] Permissions --- scripts/validate_blocks.php | 0 scripts/validate_users.php | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/validate_blocks.php mode change 100644 => 100755 scripts/validate_users.php diff --git a/scripts/validate_blocks.php b/scripts/validate_blocks.php old mode 100644 new mode 100755 diff --git a/scripts/validate_users.php b/scripts/validate_users.php old mode 100644 new mode 100755 From b8aa9f87383875218a9b19256fea9ca6a56b95c5 Mon Sep 17 00:00:00 2001 From: rog1121 Date: Sun, 2 Mar 2014 12:07:22 -0700 Subject: [PATCH 12/16] Update getusertransactions.inc.php --- public/include/pages/api/getusertransactions.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/include/pages/api/getusertransactions.inc.php b/public/include/pages/api/getusertransactions.inc.php index 403ff929..c150d093 100644 --- a/public/include/pages/api/getusertransactions.inc.php +++ b/public/include/pages/api/getusertransactions.inc.php @@ -8,13 +8,13 @@ $api->isActive(); $user_id = $api->checkAccess($user->checkApiKey($_REQUEST['api_key']), @$_REQUEST['id']); // Fetch transactions -if (isset($_REQUEST['limit']) && $_REQUEST['limit'] < 30) { +if (isset($_REQUEST['limit']) && $_REQUEST['limit'] =< 100) { $limit = $_REQUEST['limit']; } else { // Force limit - $limit = 5; + $limit = 100; } -$data['transactions'] = $transaction->getTransactions(0, NULL, 30, $user_id); +$data['transactions'] = $transaction->getTransactions(0, NULL, $limit, $user_id); // Fetch summary if enabled if (!$setting->getValue('disable_transactionsummary')) { From 73f4cafc28efad8d3f8b01a0266a15d9f498829e Mon Sep 17 00:00:00 2001 From: rog1121 Date: Sun, 2 Mar 2014 12:16:14 -0700 Subject: [PATCH 13/16] Use Defined Limit --- public/include/pages/api/getusertransactions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/include/pages/api/getusertransactions.inc.php b/public/include/pages/api/getusertransactions.inc.php index c150d093..3903deba 100644 --- a/public/include/pages/api/getusertransactions.inc.php +++ b/public/include/pages/api/getusertransactions.inc.php @@ -8,7 +8,7 @@ $api->isActive(); $user_id = $api->checkAccess($user->checkApiKey($_REQUEST['api_key']), @$_REQUEST['id']); // Fetch transactions -if (isset($_REQUEST['limit']) && $_REQUEST['limit'] =< 100) { +if (isset($_REQUEST['limit']) && $_REQUEST['limit'] <= 100) { $limit = $_REQUEST['limit']; } else { // Force limit From 863dbb56ebaf2b4db1416c01c04965d7a500add6 Mon Sep 17 00:00:00 2001 From: iAmShorty Date: Mon, 3 Mar 2014 08:41:44 +0100 Subject: [PATCH 14/16] [FIX] fixed nethashrate for some coins --- public/include/classes/bitcoinwrapper.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/include/classes/bitcoinwrapper.class.php b/public/include/classes/bitcoinwrapper.class.php index 91af6ad2..9e90069f 100644 --- a/public/include/classes/bitcoinwrapper.class.php +++ b/public/include/classes/bitcoinwrapper.class.php @@ -74,6 +74,10 @@ class BitcoinWrapper extends BitcoinClient { if (is_array($dNetworkHashrate)) { if (array_key_exists('networkhashps', $dNetworkHashrate)) { $dNetworkHashrate = $dNetworkHashrate['networkhashps']; + } else if (array_key_exists('networkmhps', $dNetworkHashrate)) { + $dNetworkHashrate = $dNetworkHashrate['networkmhps'] / 1000; + } else if (array_key_exists('networkghps', $dNetworkHashrate)) { + $dNetworkHashrate = $dNetworkHashrate['networkghps'] / 1000 / 1000; } else if (array_key_exists('hashespersec', $dNetworkHashrate)) { $dNetworkHashrate = $dNetworkHashrate['hashespersec']; } else if (array_key_exists('netmhashps', $dNetworkHashrate)) { From f891743aed3b8be10b3277d2aab4d09393ddbb56 Mon Sep 17 00:00:00 2001 From: iAmShorty Date: Mon, 3 Mar 2014 08:50:12 +0100 Subject: [PATCH 15/16] [FIX] fixed calculation --- public/include/classes/bitcoinwrapper.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/include/classes/bitcoinwrapper.class.php b/public/include/classes/bitcoinwrapper.class.php index 9e90069f..4777a87c 100644 --- a/public/include/classes/bitcoinwrapper.class.php +++ b/public/include/classes/bitcoinwrapper.class.php @@ -75,9 +75,9 @@ class BitcoinWrapper extends BitcoinClient { if (array_key_exists('networkhashps', $dNetworkHashrate)) { $dNetworkHashrate = $dNetworkHashrate['networkhashps']; } else if (array_key_exists('networkmhps', $dNetworkHashrate)) { - $dNetworkHashrate = $dNetworkHashrate['networkmhps'] / 1000; + $dNetworkHashrate = $dNetworkHashrate['networkmhps'] * 1000; } else if (array_key_exists('networkghps', $dNetworkHashrate)) { - $dNetworkHashrate = $dNetworkHashrate['networkghps'] / 1000 / 1000; + $dNetworkHashrate = $dNetworkHashrate['networkghps'] * 1000 * 1000; } else if (array_key_exists('hashespersec', $dNetworkHashrate)) { $dNetworkHashrate = $dNetworkHashrate['hashespersec']; } else if (array_key_exists('netmhashps', $dNetworkHashrate)) { From a1dbe8bb09cdf3e536fee8c27fa03269343d43b0 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 3 Mar 2014 09:42:36 +0100 Subject: [PATCH 16/16] [FIX] Workaround for missing confirmations This will fix issues with those coins that don't track confirmations for blocks inside the getblock RPC call. It will try to fallback to the transactions confirmations and insert those instead. Fixes #1823 as mentioned by @ice00 - Thanks for that! --- cronjobs/blockupdate.php | 14 +++++++++++--- public/include/config/error_codes.inc.php | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cronjobs/blockupdate.php b/cronjobs/blockupdate.php index f7938dee..c1ef23b5 100755 --- a/cronjobs/blockupdate.php +++ b/cronjobs/blockupdate.php @@ -54,10 +54,18 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { $log->logInfo(sprintf($strLogMask, $aBlock['id'], $aBlock['height'], $aBlock['blockhash'], $aBlock['confirmations'], $aBlockInfo['confirmations'], $status)); continue; } - if ($aBlock['confirmations'] == $aBlockInfo['confirmations']) { + if (isset($aBlockInfo['confirmations'])) { + $iRPCConfirmations = $aBlockInfo['confirmations']; + } else if (isset($aTxDetails['confirmations'])) { + $iRPCConfirmations = $aTxDetails['confirmations']; + } else { + $log->logFatal(' RPC does not return any usable block confirmation information'); + $monitoring->endCronjob($cron_name, 'E0082', 1, true); + } + if ($iRPCConfirmations == $aBlock['confirmations']) { continue; } else { - if (!$block->setConfirmations($aBlock['id'], $aBlockInfo['confirmations'])) { + if (!$block->setConfirmations($aBlock['id'], $iRPCConfirmations)) { $log->logError(' Failed to update block confirmations: ' . $block->getCronMessage()); $status = 'ERROR'; } else { @@ -67,7 +75,7 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { $log->logInfo(sprintf($strLogMask, 'ID', 'Height', 'Blockhash', 'Old', 'New', 'Status')); $header = true; } - $log->logInfo(sprintf($strLogMask, $aBlock['id'], $aBlock['height'], $aBlock['blockhash'], $aBlock['confirmations'], $aBlockInfo['confirmations'], $status)); + $log->logInfo(sprintf($strLogMask, $aBlock['id'], $aBlock['height'], $aBlock['blockhash'], $aBlock['confirmations'], $iRPCConfirmations, $status)); } } diff --git a/public/include/config/error_codes.inc.php b/public/include/config/error_codes.inc.php index b6e720ee..7d24bdae 100644 --- a/public/include/config/error_codes.inc.php +++ b/public/include/config/error_codes.inc.php @@ -77,4 +77,5 @@ $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'; $aErrorCodes['E0081'] = 'Failed to insert new block into database'; +$aErrorCodes['E0082'] = 'Block does not supply any usable confirmation information'; ?>