Skip to content

Commit 5fc516f

Browse files
committed
Merge pull request #1890 from mxaddict/master
Pull request for findblock cron fix, related to orphaned blocks.
2 parents b67c3f9 + 338154b commit 5fc516f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

cronjobs/findblock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
require_once('shared.inc.php');
2727

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

public/include/classes/block.class.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ public function getLast() {
1515
return $result->fetch_assoc();
1616
return $this->sqlError();
1717
}
18+
19+
/**
20+
* Specific method to fetch the latest block found that is VALID
21+
* @param none
22+
* @return data array Array with database fields as keys
23+
**/
24+
public function getLastValid() {
25+
$stmt = $this->mysqli->prepare("SELECT * FROM $this->table WHERE confirmations > -1 ORDER BY height DESC LIMIT 1");
26+
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result())
27+
return $result->fetch_assoc();
28+
return $this->sqlError();
29+
}
1830

1931
/**
2032
* Get a specific block, by block height

0 commit comments

Comments
 (0)