diff --git a/cronjobs/findblock.php b/cronjobs/findblock.php index 0c8dfeca..4ee9f644 100755 --- a/cronjobs/findblock.php +++ b/cronjobs/findblock.php @@ -25,7 +25,6 @@ chdir(dirname(__FILE__)); // Include all settings and classes require_once('shared.inc.php'); - // Fetch our last block found from the DB as a starting point $aLastBlock = @$block->getLast(); $strLastBlockHash = $aLastBlock['blockhash']; @@ -66,7 +65,8 @@ if (empty($aTransactions['transactions'])) { continue; } if (!$block->addBlock($aData) ) { - $log->logFatal('Unable to add block: ' . $aData['height'] . ': ' . $block->getCronError()); + $log->logFatal('Unable to add block: (' . $aData['height'] . ') ' . $aData['blockhash'] . ': ' . $block->getCronError()); + $monitoring->endCronjob($cron_name, 'E0081', 1, true); } } } diff --git a/public/include/config/error_codes.inc.php b/public/include/config/error_codes.inc.php index d8be9eb3..b6e720ee 100644 --- a/public/include/config/error_codes.inc.php +++ b/public/include/config/error_codes.inc.php @@ -76,4 +76,5 @@ $aErrorCodes['E0077'] = 'RPC method or connection failed'; $aErrorCodes['E0078'] = 'RPC method did not return 200 OK'; $aErrorCodes['E0079'] = 'Wallet does not cover payouts total amount'; $aErrorCodes['E0080'] = 'No new unaccounted shares since last run'; +$aErrorCodes['E0081'] = 'Failed to insert new block into database'; ?> diff --git a/public/include/pages/statistics/blocks.inc.php b/public/include/pages/statistics/blocks.inc.php index ccffdb3a..90ea8425 100644 --- a/public/include/pages/statistics/blocks.inc.php +++ b/public/include/pages/statistics/blocks.inc.php @@ -13,18 +13,21 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { } $iHeight = 0; - if (@$_REQUEST['next'] && !empty($_REQUEST['height']) && is_numeric($_REQUEST['height'])) { - $iHeight = @$roundstats->getNextBlockForStats($_REQUEST['height'], $iLimit); - if (!$iHeight) { - $iBlock = $block->getLast(); - $iHeight = $iBlock['height']; - } - } else if (@$_REQUEST['prev'] && !empty($_REQUEST['height']) && is_numeric($_REQUEST['height'])) { - $iHeight = $_REQUEST['height']; + if (@$_REQUEST['next'] && !empty($_REQUEST['height'])) { + $iHeight = @$roundstats->getNextBlock($_REQUEST['height']); + if (!$iHeight) { + $iBlock = $block->getLast(); + $iHeight = $iBlock['height']; + } + } else if (@$_REQUEST['prev'] && !empty($_REQUEST['height'])) { + $iHeight = $roundstats->getPreviousBlock($_REQUEST['height']); } else if (empty($_REQUEST['height'])) { - $aBlock = $block->getLast(); - $iHeight = $aBlock['height']; + $iBlock = $block->getLast(); + $iHeight = $iBlock['height']; + } else { + $iHeight = $_REQUEST['height']; } + $_REQUEST['height'] = $iHeight; $test = false; if (@$_REQUEST['test'] && $user->isAdmin($_SESSION['USERDATA']['id'])) { @@ -48,8 +51,8 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { } } } else if ($config['payout_system'] == 'prop' || $config['payout_system'] == 'pps') { - if ($setting->getValue('statistics_show_block_average') && !$test) { - foreach($aBlocksFoundData as $key => $aData) { + if ($setting->getValue('statistics_show_block_average') && !$test) { + foreach($aBlocksFoundData as $key => $aData) { $aBlocksFoundData[$key]['block_avg'] = round($block->getAvgBlockShares($aData['height'], $config['pplns']['blockavg']['blockcount'])); $use_average = true; } diff --git a/public/templates/bootstrap/statistics/blocks/block_shares_graph.tpl b/public/templates/bootstrap/statistics/blocks/block_shares_graph.tpl index 611b859a..9c768fb4 100644 --- a/public/templates/bootstrap/statistics/blocks/block_shares_graph.tpl +++ b/public/templates/bootstrap/statistics/blocks/block_shares_graph.tpl @@ -44,6 +44,8 @@ $(function () {