Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

52 rindas
1.1 KiB

<?php
// ---
// --- Listening to blockchain.info to get the last block
// ---
// ---
// --- La config globale
// ---
require_once '../global/inc/config.php';
// ---
// --- Internal dependances
// ---
require_once 'inc/block.php';
// ---
// --- Par défaut on cherche le dernier block
// ---
$block_hash = 'LAST';
// ---
// --- Le cas échéant, on cherche block passé en argument
// ---
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();
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'))
	{
		$block_hash = $the_block->prev_block;
		$the_block = blockchain::getSpecialBlock($block_hash);
		if ($the_block === FALSE) die();
		// Mais pas plus de 5 blocs de retard ...
		$max += 1;if ($max > 5) break;
	}
}
echo $the_block->hash." ".$the_block->height.PHP_EOL;
?>