From dc4d1b3b8e93df06c7b814380891e633245ecf79 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 11 Nov 2013 12:24:54 +0100 Subject: [PATCH 1/4] [FIX] Class Warning on new pools --- public/include/classes/statistics.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index 30bdb078..be80e77f 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -31,7 +31,7 @@ class Statistics extends Base { if ($data = $this->memcache->get(__FUNCTION__)) return $data; $stmt = $this->mysqli->prepare(" SELECT - time FROM " . $this->block->getTableName() . " + IFNULL(time, 0) AS time FROM " . $this->block->getTableName() . " ORDER BY id ASC LIMIT 1"); if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_object()->time; From 629dfb58ed85c857e19160596f55479e812fc0a9 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 11 Nov 2013 12:30:36 +0100 Subject: [PATCH 2/4] [FIX] Name of Uptime Robot Setting --- public/include/pages/statistics/uptime.inc.php | 2 +- public/include/smarty_globals.inc.php | 2 +- public/templates/mmcFE/global/navigation.tpl | 4 ++-- public/templates/mpos/global/navigation.tpl | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/public/include/pages/statistics/uptime.inc.php b/public/include/pages/statistics/uptime.inc.php index df5cca83..3e321e7f 100644 --- a/public/include/pages/statistics/uptime.inc.php +++ b/public/include/pages/statistics/uptime.inc.php @@ -5,7 +5,7 @@ if (!defined('SECURITY')) die('Hacking attempt'); if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { $debug->append('No cached version available, fetching from backend', 3); - if ($setting->getValue('monitoring_uptimerobot_private_key')) { + if ($setting->getValue('monitoring_uptimerobot_api_keys')) { if ($aStatus = $monitoring->getUptimeRobotStatus()) { $smarty->assign("STATUS", $aStatus); $smarty->assign("UPDATED", $setting->getValue('monitoring_uptimerobot_lastcheck')); diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index 42406331..a3dc2f0a 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -69,7 +69,7 @@ $aGlobal = array( 'accounts' => $config['accounts'], 'disable_invitations' => $setting->getValue('disable_invitations'), 'disable_notifications' => $setting->getValue('disable_notifications'), - 'monitoring_uptimerobot_private_key' => $setting->getValue('monitoring_uptimerobot_private_key'), + 'monitoring_uptimerobot_api_keys' => $setting->getValue('monitoring_uptimerobot_api_keys'), 'statistics_ajax_refresh_interval' => $statistics_ajax_refresh_interval, 'price' => array( 'currency' => $config['price']['currency'] ), 'targetdiff' => $config['difficulty'], diff --git a/public/templates/mmcFE/global/navigation.tpl b/public/templates/mmcFE/global/navigation.tpl index 32968c99..82754506 100644 --- a/public/templates/mmcFE/global/navigation.tpl +++ b/public/templates/mmcFE/global/navigation.tpl @@ -33,7 +33,7 @@
  • Block Stats
  • Hashrate Graphs
  • Round Stats
  • - {if $GLOBAL.config.monitoring_uptimerobot_private_key|default:"0"}
  • Uptime Stats
  • {/if} + {if $GLOBAL.config.monitoring_uptimerobot_api_keys|default:"0"}
  • Uptime Stats
  • {/if} {else} @@ -49,7 +49,7 @@
  • Round Stats
  • {/if} {if $GLOBAL.acl.uptime.statistics} - {if $GLOBAL.config.monitoring_uptimerobot_private_key|default:"0"}
  • Uptime Stats
  • {/if} + {if $GLOBAL.config.monitoring_uptimerobot_api_keys|default:"0"}
  • Uptime Stats
  • {/if} {/if} {/if} diff --git a/public/templates/mpos/global/navigation.tpl b/public/templates/mpos/global/navigation.tpl index 55e5a369..39c5ee84 100644 --- a/public/templates/mpos/global/navigation.tpl +++ b/public/templates/mpos/global/navigation.tpl @@ -33,7 +33,7 @@
  • Blocks
  • Graphs
  • Round
  • - {if $GLOBAL.config.monitoring_uptimerobot_private_key|default:"0"}
  • Uptime
  • {/if} + {if $GLOBAL.config.monitoring_uptimerobot_api_keys|default:"0"}
  • Uptime
  • {/if} {else}

    Statistics

    @@ -50,7 +50,7 @@
  • Round
  • {/if} {if $GLOBAL.acl.uptime.statistics} - {if $GLOBAL.config.monitoring_uptimerobot_private_key|default:"0"}
  • Uptime
  • {/if} + {if $GLOBAL.config.monitoring_uptimerobot_api_keys|default:"0"}
  • Uptime
  • {/if} {/if} {/if} From 9ccc3403f8a537ee7d8a50c2b0f5439a1130f1f4 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 11 Nov 2013 12:42:35 +0100 Subject: [PATCH 3/4] [UPDATED] Query improved for first blocks time --- public/include/classes/statistics.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index be80e77f..bae7ed81 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -30,9 +30,7 @@ class Statistics extends Base { $this->debug->append("STA " . __METHOD__, 4); if ($data = $this->memcache->get(__FUNCTION__)) return $data; $stmt = $this->mysqli->prepare(" - SELECT - IFNULL(time, 0) AS time FROM " . $this->block->getTableName() . " - ORDER BY id ASC LIMIT 1"); + SELECT IFNULL(MIN(time), 0) AS time FROM " . $this->block->getTableName()); if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_object()->time; return false; From d155804a060797b9c7df51bfe5f2915f24818331 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 11 Nov 2013 12:51:06 +0100 Subject: [PATCH 4/4] [FIX] Skip payouts until block has a share_id --- cronjobs/pplns_payout.php | 7 +++++++ cronjobs/proportional_payout.php | 7 +++++++ public/include/config/error_codes.inc.php | 1 + 3 files changed, 15 insertions(+) diff --git a/cronjobs/pplns_payout.php b/cronjobs/pplns_payout.php index 73ce4a17..8d60ae2e 100755 --- a/cronjobs/pplns_payout.php +++ b/cronjobs/pplns_payout.php @@ -40,6 +40,12 @@ if (empty($aAllBlocks)) { $count = 0; foreach ($aAllBlocks as $iIndex => $aBlock) { + // If we have unaccounted blocks without share_ids, they might not have been inserted yet + if (!$aBlock['share_id']) { + $log->logError('E0062: Block has no share_id, not running payouts'); + $monitoring->endCronjob($cron_name, 'E0062', 0, true); + } + // We support some dynamic share targets but fall back to our fixed value // Re-calculate after each run due to re-targets in this loop if ($config['pplns']['shares']['type'] == 'blockavg' && $block->getBlockCount() > 0) { @@ -50,6 +56,7 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { $pplns_target = $config['pplns']['shares']['default']; } + // Fetch our last paid block information if ($iLastBlockId = $setting->getValue('last_accounted_block_id')) { $aLastAccountedBlock = $block->getBlockById($iLastBlockId); } else { diff --git a/cronjobs/proportional_payout.php b/cronjobs/proportional_payout.php index 49ab7a94..59819b29 100755 --- a/cronjobs/proportional_payout.php +++ b/cronjobs/proportional_payout.php @@ -42,6 +42,13 @@ $count = 0; // Table header for account shares $log->logInfo("ID\tUsername\tValid\tInvalid\tPercentage\tPayout\t\tDonation\tFee"); foreach ($aAllBlocks as $iIndex => $aBlock) { + // If we have unaccounted blocks without share_ids, they might not have been inserted yet + if (!$aBlock['share_id']) { + $log->logError('E0062: Block has no share_id, not running payouts'); + $monitoring->endCronjob($cron_name, 'E0062', 0, true); + } + + // Fetch last paid block information if ($iLastBlockId = $setting->getValue('last_accounted_block_id')) { $aLastAccountedBlock = $block->getBlockById($iLastBlockId); } else { diff --git a/public/include/config/error_codes.inc.php b/public/include/config/error_codes.inc.php index b48622c3..5eda21da 100644 --- a/public/include/config/error_codes.inc.php +++ b/public/include/config/error_codes.inc.php @@ -65,4 +65,5 @@ $aErrorCodes['E0058'] = 'Worker name and/or password must not be empty'; $aErrorCodes['E0059'] = 'Worker already exists'; $aErrorCodes['E0060'] = 'Failed to add new worker'; $aErrorCodes['E0061'] = 'Failed to delete worker'; +$aErrorCodes['E0062'] = 'Block has no share_id, not running payouts'; ?>