100 blocks

This commit is contained in:
2024-01-28 13:13:47 +01:00
parent 06e604f268
commit be73b23564
19 changed files with 573 additions and 107 deletions
+6
View File
@@ -1,4 +1,10 @@
[
{
"hash": "00000000000000000000a63021c17572b66507c6b6623ccf4e780272d19b2528",
"height": 824513,
"name": "BURN2024",
"desc": "Le 03 janvier 2024, Binance a envoyé 26,9 BTC (valorisés 1,2 millions de dollars) sur un Genesis Wallet"
},
{
"hash": "00000000000000000001e6d99b42a2fe649591e7b97b1d4327e2bc3ade53d6d7",
"height": 772923,
+7
View File
@@ -0,0 +1,7 @@
[
{
"hash":"a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d",
"name":"Pizza Transaction",
"desc":"This transaction was made by Laszlo Hanyecz in 2010 where he paid Jeremy Sturdivant 10,000 bitcoin for two pizzas bought at Papa John's"
}
]
+17 -2
View File
@@ -335,13 +335,15 @@ class blockchain
{
$path = APP_PATH.'/blockchain/data/blocks.json';
$jsonString = file_get_contents($path);
self::$special_blocks = json_decode($jsonString, true);
if ($jsonString === FALSE) die('blocks spéciaux non trouvés');
$blocks = json_decode($jsonString, true);
foreach($blocks as $block)
self::$special_blocks[] = new block($block["hash"],$block["height"],$block["name"],$block["desc"]);
}
public static function init(){
self::init_v2();
}
// ---
// --- Retourne le JSON du tableau des blocs speciaux
// ---
@@ -387,18 +389,31 @@ class blockchain
return self::getBlockWithHash($block_hash);
}
// ----
// ----
public static function getSpecialBlockList()
{
foreach(self::$special_blocks as $block)
{
$the_block=self::getBlockWithHash($block->hash);
echo $block->name.' '.$the_block->hash." ".$the_block->height." ".$the_block->n_tx.PHP_EOL;
}
}
// ---
// --- Accès au dernier block en cache ...
// ---
public static function getLastCacheBlockHash()
{
// on commence par le cache d'images
/*
$myarray = glob(DATA_PATH.'/hasard/*.png');
if (isset($myarray[0]))
{
usort( $myarray, function( $a, $b ) { return filemtime($b) - filemtime($a); } );
return substr(basename($myarray[0],'.png'),0,strlen(self::$special_blocks[0]->hash));
}
*/
// S'il n'y a rien dans le cache d'images
$filename=DATA_PATH.'/finished_block_list.txt';
+14 -23
View File
@@ -14,34 +14,25 @@ require_once '../global/inc/config.php';
// ---
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];
// ---
// --- 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;
blockchain::getSpecialBlocklist();
if ($block_hash == 'LAST')
$the_block = blockchain::getBlockWithHash(blockchain::getLastBlockHash());
if ($the_block === FALSE) die();
echo 'LAST '.$the_block->hash." ".$the_block->height." ".$the_block->n_tx.PHP_EOL;
exit(0);
// On a demandé le dernier block
// On remonte sur les huits derniers pour accélerer les prochaines navigations
for($max=0;($max<8)&&(!file_exists(DATA_PATH.'/json/'.$the_block->prev_block.'.zip'));$max++)
{
// On a demandé le dernier block
// On remonte sur les huits derniers pour accélerer les prochaines navigations
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::getBlockWithHash($block_hash);
if ($the_block === FALSE) die();
echo 'CACHE '.$the_block->hash." ".$the_block->height." ".$the_block->n_tx.PHP_EOL;
}
$block_hash = $the_block->prev_block;
$the_block = blockchain::getBlockWithHash($block_hash);
if ($the_block === FALSE) die();
echo 'CACHE '.$the_block->hash." ".$the_block->height." ".$the_block->n_tx.PHP_EOL;
}
?>
+1 -20
View File
@@ -13,26 +13,7 @@ cd $APPS_PATH/blockchain
rm -f $DATA_PATH/block_list.tmp
LISTBLOCKS="GENESIS THE_ANSWER LUCIFER LEET \
TOPISTO PIZZA HALVING_1 WHALE201311 \
JOHN_CONWAY DORMEUR_ORIGINE \
HALVING_2 BIP_91_LOCK BCC SEGWIT_LOCK \
SEGWIT HURRICANE_1 WHALE201810 \
WHALE201909 WHALE20201026 \
BLOCK21E800 GOLGOTH201909 EQUILIBRE \
DEMISSION20200110 2020JUMP9000 \
SOPHIA202002 EQUILIBRE202002 COVID19 \
RIP_STEEVE HALVING_3 DORMEUR \
FIRST_USD_TX 2020JUMP10000 \
NO_REWARD MORNING_STAR SALVADOR \
BAB_BRUXELLES POITIERS UKRAINE \
ELISABETH_2_HAS_DIED BERNIQUE \
LAST"
for BLOCK in $LISTBLOCKS
do
php robot.php $BLOCK >> $DATA_PATH/block_list.tmp
done
php robot.php > $DATA_PATH/block_list.tmp
# Sort the block list by Height
sort -k3 -n $DATA_PATH/block_list.tmp > $DATA_PATH/block_list.txt