diff --git a/blockchain/cache.php b/blockchain/cache.php deleted file mode 100644 index 91a3835..0000000 --- a/blockchain/cache.php +++ /dev/null @@ -1,46 +0,0 @@ - Ce qui a pour effet de placer le block dans le cache -// --- -$the_block = blockchain::getSpecialBlock($block_hash); -if ($the_block === FALSE) die(); - -// --- -// --- On en recherche 6 sur approximativement 6 heures (36 blocks) -// --- -$max = 6; -while($max > 0) -{ - $block_hash = $the_block->prev_block; - - if (!file_exists(DATA_PATH.'/json/'.$block_hash.'.zip')) - echo 'CACHE '.$block_hash.' '.($the_block->height-1)." ".$the_block->n_tx.PHP_EOL; - - $the_block = blockchain::getBlockWithHash($block_hash); - if ($the_block === FALSE) die(); - - $max--; -} - -?> diff --git a/blockchain/controle_cache.php b/blockchain/controle_cache.php deleted file mode 100644 index 93cb5c1..0000000 --- a/blockchain/controle_cache.php +++ /dev/null @@ -1,46 +0,0 @@ - Ce qui a pour effet de placer le block dans le cache -// --- -$block_hash = blockchain::getLastBlockHash(); -if ($block_hash === FALSE) die(); -echo 'LAST '.$block_hash.' ZIP OK PNG OK'; - -for($i=0;$i<36;$i++) -{ - $the_block = blockchain::getBlockWithHash($block_hash); - if ($the_block === FALSE) die(); - - echo ' '.$the_block->height.PHP_EOL; - if ($i == 35) break; - - $block_hash = $the_block->prev_block; - echo 'PREV '.$block_hash.' '; - - echo 'ZIP '; - if (file_exists(DATA_PATH.'/json/'.$the_block->hash.'.zip')) echo 'OK '; - else echo 'KO '; - - echo 'PNG '; - if (file_exists(DATA_PATH.'/hasard/'.$the_block->hash.'.png')) echo 'OK'; - else echo 'KO'; -} - -?> -~ \ No newline at end of file diff --git a/blockchain/include.php b/blockchain/include.php deleted file mode 100644 index aa4e5a4..0000000 --- a/blockchain/include.php +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/blockchain/last.php b/blockchain/last.php deleted file mode 100644 index 135df5b..0000000 --- a/blockchain/last.php +++ /dev/null @@ -1,47 +0,0 @@ - Ce qui a pour effet de placer le block dans le cache -// --- -block_hash = blockchain::getLastCacheBlockHash(); -if ($block_hash === FALSE) die(); -$the_block = blockchain::getBlockWithHash($block_hash); -echo 'LAST '.$block_hash.' '.$the_block->height.PHP_EOL; - -$block_hash = blockchain::getLastBlockHash(); -if ($block_hash === FALSE) die(); -$the_block = blockchain::getBlockWithHash($block_hash); -echo 'LAST '.$block_hash.' '.$the_block->height.PHP_EOL; - -$the_block = blockchain::getSpecialBlock('LAST'); -if ($the_block === FALSE) die(); -echo 'LAST '.$the_block->hash." ".$the_block->height.PHP_EOL; - -$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::getBlockWithHash($block_hash); - if ($the_block === FALSE) die(); - // Mais pas plus de 5 blocs de retard ... - $max += 1;if ($max > 5) break; -} -echo 'LAST '.$the_block->hash." ".$the_block->height.PHP_EOL; - -?> diff --git a/blockchain/robot.php b/blockchain/robot.php index 26fa8b7..d7f59e4 100644 --- a/blockchain/robot.php +++ b/blockchain/robot.php @@ -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; ?> diff --git a/blockchain/robot.sh b/blockchain/robot.sh index e982133..a447267 100755 --- a/blockchain/robot.sh +++ b/blockchain/robot.sh @@ -11,19 +11,22 @@ touch $flag cd $APPS_PATH/blockchain -rm -f $DATA_PATH/block_list.txt +rm -f $DATA_PATH/block_list.tmp -php cache.php >> $DATA_PATH/block_list.txt - -LISTBLOCKS="GENESIS THE_ANSWER LUCIFER LEET \ - TOPISTO PIZZA HALVING_1 WHALE201311 HALVING_2 \ - BIP_91_LOCK BCC SEGWIT_LOCK SEGWIT \ - HURRICANE_1 WHALE201810 BLOCK21E800 \ - LAST" +LISTBLOCKS="LAST \ + GENESIS THE_ANSWER LUCIFER LEET \ + TOPISTO PIZZA HALVING_1 WHALE201311 \ + HALVING_2 BIP_91_LOCK BCC SEGWIT_LOCK \ + SEGWIT HURRICANE_1 WHALE201810 \ + BLOCK21E800" for BLOCK in $LISTBLOCKS do - php robot.php $BLOCK >> $DATA_PATH/block_list.txt + php robot.php $BLOCK >> $DATA_PATH/block_list.tmp done +# Sort the block list by Height +sort -k3 -n $DATA_PATH/block_list.tmp > $DATA_PATH/block_list.txt + +rm -f $DATA_PATH/block_list.tmp rm -f $flag