Skip to content

Commit 9fc1a39

Browse files
committed
Merge pull request #1899 from MPOS/findblocks-workaround
[WORKAROUND] Blocks without confirmations
2 parents 59b7c36 + b77fec0 commit 9fc1a39

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cronjobs/findblock.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@
5858
$aBlockRPCInfo = $bitcoin->getblock($aData['blockhash']);
5959
$config['reward_type'] == 'block' ? $aData['amount'] = $aData['amount'] : $aData['amount'] = $config['reward'];
6060
$aData['height'] = $aBlockRPCInfo['height'];
61+
$aTxDetails = $bitcoin->gettransaction($aBlockRPCInfo['tx'][0]);
62+
if (!isset($aBlockRPCInfo['confirmations'])) {
63+
$aData['confirmations'] = $aBlockRPCInfo['confirmations'];
64+
} else if (isset($aTxDetails['confirmations'])) {
65+
$aData['confirmations'] = $aTxDetails['confirmations'];
66+
} else {
67+
$log->logFatal(' RPC does not return any usable block confirmation information');
68+
$monitoring->endCronjob($cron_name, 'E0082', 1, true);
69+
}
6170
$aData['difficulty'] = $aBlockRPCInfo['difficulty'];
6271
$log->logInfo(sprintf($strLogMask, substr($aData['blockhash'], 0, 17)."...", $aData['height'], $aData['amount'], $aData['confirmations'], $aData['difficulty'], strftime("%Y-%m-%d %H:%M:%S", $aData['time'])));
6372
if ( ! empty($aBlockRPCInfo['flags']) && preg_match('/proof-of-stake/', $aBlockRPCInfo['flags']) ) {

0 commit comments

Comments
 (0)