Adding block height to blockupdate output
This should make tracing block updates easier.
This commit is contained in:
parent
da1649f319
commit
dc51d874a7
@ -30,12 +30,12 @@ if ( $bitcoin->can_connect() !== true ) {
|
|||||||
// Fetch all unconfirmed blocks
|
// Fetch all unconfirmed blocks
|
||||||
$aAllBlocks = $block->getAllUnconfirmed($config['confirmations']);
|
$aAllBlocks = $block->getAllUnconfirmed($config['confirmations']);
|
||||||
|
|
||||||
$log->logInfo("ID\tBlockhash\tConfirmations");
|
$log->logInfo("ID\tHeight\tBlockhash\tConfirmations");
|
||||||
foreach ($aAllBlocks as $iIndex => $aBlock) {
|
foreach ($aAllBlocks as $iIndex => $aBlock) {
|
||||||
$aBlockInfo = $bitcoin->query('getblock', $aBlock['blockhash']);
|
$aBlockInfo = $bitcoin->query('getblock', $aBlock['blockhash']);
|
||||||
// Fetch this blocks transaction details to find orphan blocks
|
// Fetch this blocks transaction details to find orphan blocks
|
||||||
$aTxDetails = $bitcoin->query('gettransaction', $aBlockInfo['tx'][0]);
|
$aTxDetails = $bitcoin->query('gettransaction', $aBlockInfo['tx'][0]);
|
||||||
$log->logInfo($aBlock['id'] . "\t" . $aBlock['blockhash'] . "\t" . $aBlock['confirmations'] . " -> " . $aBlockInfo['confirmations']);
|
$log->logInfo($aBlock['id'] . "\t" . $aBlock['height'] . "\t" . $aBlock['blockhash'] . "\t" . $aBlock['confirmations'] . " -> " . $aBlockInfo['confirmations']);
|
||||||
if ($aTxDetails['details'][0]['category'] == 'orphan') {
|
if ($aTxDetails['details'][0]['category'] == 'orphan') {
|
||||||
// We have an orphaned block, we need to invalidate all transactions for this one
|
// We have an orphaned block, we need to invalidate all transactions for this one
|
||||||
if ($transaction->setOrphan($aBlock['id']) && $block->setConfirmations($aBlock['id'], -1)) {
|
if ($transaction->setOrphan($aBlock['id']) && $block->setConfirmations($aBlock['id'], -1)) {
|
||||||
|
|||||||
@ -85,14 +85,9 @@ class Block {
|
|||||||
* @return data array Array with database fields as keys
|
* @return data array Array with database fields as keys
|
||||||
**/
|
**/
|
||||||
public function getAllUnconfirmed($confirmations='120') {
|
public function getAllUnconfirmed($confirmations='120') {
|
||||||
$stmt = $this->mysqli->prepare("SELECT id, blockhash, confirmations FROM $this->table WHERE confirmations < ? AND confirmations > -1");
|
$stmt = $this->mysqli->prepare("SELECT id, height, blockhash, confirmations FROM $this->table WHERE confirmations < ? AND confirmations > -1");
|
||||||
if ($this->checkStmt($stmt)) {
|
if ($this->checkStmt($stmt) && $stmt->bind_param("i", $confirmations) && $stmt->execute() && $result = $stmt->get_result())
|
||||||
$stmt->bind_param("i", $confirmations);
|
|
||||||
$stmt->execute();
|
|
||||||
$result = $stmt->get_result();
|
|
||||||
$stmt->close();
|
|
||||||
return $result->fetch_all(MYSQLI_ASSOC);
|
return $result->fetch_all(MYSQLI_ASSOC);
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user