Merge pull request #1890 from mxaddict/master

Pull request for findblock cron fix, related to orphaned blocks.
This commit is contained in:
Sebastian Grewe 2014-03-06 09:43:05 +01:00
commit 5fc516f6b9
2 changed files with 13 additions and 1 deletions

View File

@ -26,7 +26,7 @@ chdir(dirname(__FILE__));
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 = '';

View File

@ -15,6 +15,18 @@ class Block extends Base {
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