fixed orphan detection
This commit is contained in:
parent
347a43601d
commit
f6ceace386
@ -13,25 +13,25 @@
|
|||||||
|
|
||||||
echo "Validating blocks in database against coind..". PHP_EOL;
|
echo "Validating blocks in database against coind..". PHP_EOL;
|
||||||
|
|
||||||
$mask = "| %6s | %8s | %13s | %20s | %10s | \n";
|
$mask = "| %6s | %8s | %13s | %20s | %10s |". PHP_EOL;;
|
||||||
printf($mask, 'DB-ID', 'Height', 'Confirmations', 'Time', 'Status');
|
printf($mask, 'DB-ID', 'Height', 'Confirmations', 'Time', 'Status');
|
||||||
|
|
||||||
// fetch all blocks
|
// fetch all blocks
|
||||||
$allBlocks = $block->getAll();
|
$allBlocks = $block->getAll();
|
||||||
foreach ($allBlocks as $block)
|
foreach ($allBlocks as $block)
|
||||||
{
|
{
|
||||||
$status = 'VALID';
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$blockInfo = $bitcoin->getblock($block['blockhash']);
|
if($block['confirmations']== -1) // mark orphan blocks.
|
||||||
|
$status = 'ORPHAN';
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$blockInfo = $bitcoin->getblock($block['blockhash']);
|
||||||
|
$status = 'VALID'; // if the getblock() call didn't throw an exception, it's a valid block then.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
if($block['confirmations']== -1)
|
if($e->getMessage() == 'RPC call did not return 200: HTTP error: 500 - JSON Response: [-5] Block not found')
|
||||||
{
|
|
||||||
$status = 'ORPHAN';
|
|
||||||
}
|
|
||||||
else if($e->getMessage() == 'RPC call did not return 200: HTTP error: 500 - JSON Response: [-5] Block not found')
|
|
||||||
{
|
{
|
||||||
$status = 'INVALID';
|
$status = 'INVALID';
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user