From 365a91e4074b4e2bbd14a9ba54ba9730c8cad999 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sat, 11 May 2013 17:14:43 +0200 Subject: [PATCH] ensure we only check for unaccounted blocks --- cronjobs/pps_payout.php | 2 +- public/include/classes/block.class.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index c5270cbf..33f6d676 100644 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -22,7 +22,7 @@ limitations under the License. require_once('shared.inc.php'); // Fetch our last block found from the DB as a starting point -$aAllBlocks = $block->getAll('ASC'); +$aAllBlocks = $block->getAllUnaccounted('ASC'); foreach ($aAllBlocks as $iIndex => $aBlock) { if (!$aBlock['accounted']) { $iPrevBlockTime = @$aAllBlocks[$iIndex - 1]['time']; diff --git a/public/include/classes/block.class.php b/public/include/classes/block.class.php index 11fa2b2c..9ee60596 100644 --- a/public/include/classes/block.class.php +++ b/public/include/classes/block.class.php @@ -35,6 +35,17 @@ class Block { return false; } + public function getAllUnaccounted($order='ASC') { + $stmt = $this->mysqli->prepare("SELECT * FROM $this->table WHERE accounted = 0 ORDER BY height $order"); + if ($this->checkStmt($stmt)) { + $stmt->execute(); + $result = $stmt->get_result(); + $stmt->close(); + return $result->fetch_all(MYSQLI_ASSOC); + } + return false; + } + public function getAll($order='DESC') { $stmt = $this->mysqli->prepare("SELECT * FROM $this->table ORDER BY height $order"); if ($this->checkStmt($stmt)) {