Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cronjobs/findblock.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
require_once('shared.inc.php');

// Fetch our last block found from the DB as a starting point
$aLastBlock = @$block->getLast();
$aLastBlock = @$block->getLastValid();
$strLastBlockHash = $aLastBlock['blockhash'];
if (!$strLastBlockHash) $strLastBlockHash = '';

Expand Down
12 changes: 12 additions & 0 deletions public/include/classes/block.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ public function getLast() {
return $result->fetch_assoc();
return $this->sqlError();
}

/**
* Specific method to fetch the latest block found that is VALID
* @param none
* @return data array Array with database fields as keys
**/
public function getLastValid() {
$stmt = $this->mysqli->prepare("SELECT * FROM $this->table WHERE confirmations > -1 ORDER BY height DESC LIMIT 1");
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result())
return $result->fetch_assoc();
return $this->sqlError();
}

/**
* Get a specific block, by block height
Expand Down