File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 2626require_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 ' ];
3131if (!$ strLastBlockHash ) $ strLastBlockHash = '' ;
3232
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments