ensure we only check for unaccounted blocks

This commit is contained in:
Sebastian Grewe 2013-05-11 17:14:43 +02:00
parent 3cf5049193
commit 365a91e407
2 changed files with 12 additions and 1 deletions

View File

@ -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'];

View File

@ -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)) {