rationaliser robot blockchain
This commit is contained in:
@@ -24,29 +24,21 @@ $block_hash = 'LAST';
|
||||
// ---
|
||||
if (isset($argv[1])) $block_hash = $argv[1];
|
||||
|
||||
echo $block_hash.' ';
|
||||
|
||||
// ---
|
||||
// --- On interroge la blockchain
|
||||
// --- => Ce qui a pour effet de placer le block dans le cache
|
||||
// ---
|
||||
$the_block = blockchain::getSpecialBlock($block_hash);
|
||||
if ($the_block === FALSE) die();
|
||||
echo $block_hash.' '.$the_block->hash." ".$the_block->height." ".$the_block->n_tx.PHP_EOL;
|
||||
|
||||
if ($block_hash == 'LAST')
|
||||
{
|
||||
$max = 0;
|
||||
// On se met en retard d'au moins un bloc ...
|
||||
while(!file_exists(DATA_PATH.'/json/'.$the_block->hash.'.zip'))
|
||||
for($max=0;($max<8)&&(!file_exists(DATA_PATH.'/json/'.$the_block->prev_block.'.zip'));$max++)
|
||||
{
|
||||
$block_hash = $the_block->prev_block;
|
||||
$the_block = blockchain::getSpecialBlock($block_hash);
|
||||
$the_block = blockchain::getBlockWithHash($block_hash);
|
||||
if ($the_block === FALSE) die();
|
||||
// Mais pas plus de 5 blocs de retard ...
|
||||
$max += 1;if ($max > 5) break;
|
||||
echo 'CACHE '.$the_block->hash." ".$the_block->height." ".$the_block->n_tx.PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
echo $the_block->hash." ".$the_block->height." ".$the_block->n_tx.PHP_EOL;
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user