瀏覽代碼

Ajout mode triptyque

master
MEUNIER Thibaud 1 年之前
父節點
當前提交
1b31f92d6f
共有 7 個檔案被更改,包括 644 行新增0 行删除
  1. +31
    -0
      blockchain/data/blocks.json
  2. +266
    -0
      blockchain/data/blocks.json.2
  3. +75
    -0
      methode2/lovecraft/draw.php
  4. +67
    -0
      scripts/block2.sh
  5. +23
    -0
      scripts/draw_all_empty_blocks.sh
  6. +96
    -0
      scripts/triptyque.sh
  7. +86
    -0
      triptyque/robot.php

+ 31
- 0
blockchain/data/blocks.json 查看文件

@ -1,4 +1,28 @@
[
{
"hash": "0000000000000000000320283a032748cef8227873ff4872689bf23f1cda83a5",
"height": 840000,
"name": "HALVING_4",
"desc": "Ce block marque le 4éme halving pour la blockchaîn"
},
{
"hash": "00000000000000000002b7cf7652ce547d8b94e35e367f947e380677e3d8c05a",
"height": 832405,
"name": "ATH_60k_USD",
"desc": "ATH 60K atteint au cours de ce bloc"
},
{
"hash": "00000000000000000001ccb803261355809bc46e6e1488e2b6daa828db2b4dce",
"height": 830706,
"name": "NAVALNY_HAS_DIED",
"desc": "Opposant russe Alexei Navalny, mort en detention le 16 fevrier 2024 a 47 ans"
},
{
"hash": "000000000000000000002a3983effd69337ddd75f5862715f6c9b36e0bfa3368",
"height": 828524,
"name": "REFONTE2024",
"desc": "Janvier 2024, refonte su site frontend"
},
{
"hash": "00000000000000000000a63021c17572b66507c6b6623ccf4e780272d19b2528",
"height": 824513,
@ -233,6 +257,13 @@
"name": "LUCIFER",
"desc": null
},
{
"hash": "00000000054aad44afc89e1f4e0ee9561568629273df16153e425a2eb9cbbcb9",
"height": 261,
"name": "K_SWITZER",
"desc": "Katherine SWITZER ran the BOSTON MARATHON"
},
{
"hash": "00000000d1145790a8694403d4063f323d499e655c83426834d4ce2f8dd4a2ee",
"height": 170,

+ 266
- 0
blockchain/data/blocks.json.2 查看文件

@ -0,0 +1,266 @@
[
{
"hash": "0000000000000000000320283a032748cef8227873ff4872689bf23f1cda83a5",
"height": 840000,
"name": "HALVING_4",
"desc": "Ce block marque le 4éme halving pour la blockchaîn"
},
{
"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,
"name": "BERNIQUE",
"desc": null
},
{
"hash": "00000000000000000001f5beb60d9ca47adf18db5136b558379ed533fc9f6c85",
"height": 753335,
"name": "ELISABETH_2_HAS_DIED",
"desc": null
},
{
"hash": "000000000000000000065676a19a2dfba0171b592d52f5ea7db54d45bb386400",
"height": 724697,
"name": "UKRAINE",
"desc": null
},
{
"hash": "000000000000000000031ec514b89bdac2c4786bbcc3a1a0acd1206f82181901",
"height": 718720,
"name": "POITIERS",
"desc": null
},
{
"hash": "00000000000000000000e55da58b378880e797f9f3e96811d3e64a2f801eed9a",
"height": 700700,
"name": "BAB_BRUXELLES",
"desc": null
},
{
"hash": "00000000000000000000bfade5b2979c3d47c6dd6a1e8ddf53380e8c3d736ce0",
"height": 699382,
"name": "SALVADOR",
"desc": null
},
{
"hash": "0000000000000000000b7b8574bc6fd285825ec2dbcbeca149121fc05b0c828c",
"height": 666666,
"name": "MORNING_STAR",
"desc": null
},
{
"hash": "000000000000000000070daa5861fe1e7064ef8007825431229c6c1cab2c766f",
"height": 654364,
"name": "WHALE20201026",
"desc": null
},
{
"hash": "00000000000000000005c0f74e8b00c3961d6dfbf32936edeaa300015949f3c4",
"height": 632676,
"name": "2020JUMP10000",
"desc": null
},
{
"hash": "00000000000000000000f811e171eee52157e9a95963140e62fa83610f23ea7e",
"height": 631058,
"name": "DORMEUR",
"desc": null
},
{
"hash": "000000000000000000024bead8df69990852c202db0e0097c1a12ea637d7e96d",
"height": 630000,
"name": "HALVING_3",
"desc": null
},
{
"hash": "0000000000000000001186079bbf9a5d945231236135af7a766bd34d814e7319",
"height": 628710,
"name": "RIP_STEEVE",
"desc": null
},
{
"hash": "000000000000000000099457d2aeb2b7fc8ad8adb1490814cb674dc5767ae9b9",
"height": 622453,
"name": "COVID19",
"desc": null
},
{
"hash": "00000000000000000001a3c68111789a6c2cc76f1209d1dae63b05460053eb2b",
"height": 619165,
"name": "EQUILIBRE202002",
"desc": null
},
{
"hash": "0000000000000000000f2306f08e8f34872a24dfaad3423801a91ee1626e9ea4",
"height": 618986,
"name": "SOPHIA202002",
"desc": null
},
{
"hash": "0000000000000000001085a869441fa2aa77f149a887af0ce59846ef51da6e4c",
"height": 616193,
"name": "EQUILIBRE",
"desc": null
},
{
"hash": "0000000000000000000b05f877e6e49b380f4f78b3cfb605b67439f825dba197",
"height": 613470,
"name": "2020JUMP9000",
"desc": null
},
{
"hash": "00000000000000000009e8fb4ac719a362c1c4e3df439740069ee58e2a713258",
"height": 612149,
"name": "DEMISSION20200110",
"desc": null
},
{
"hash": "000000000000000000051f84a7a1d0f5b2ddaf5682cbec5f7acb2bf5fa339725",
"height": 593879,
"name": "GOLGOTH201909",
"desc": null
},
{
"hash": "00000000000000000014fcb29e6e3b0ead3bd2e307d7f619a935f1d5323e9013",
"height": 593468,
"name": "WHALE201909",
"desc": null
},
{
"hash": "0000000000000000000f9f2dadfb8f312572183272802cbfcc4ff95b4ee6777d",
"height": 545911,
"name": "WHALE201810",
"desc": null
},
{
"hash": "00000000000000000021e800c1e8df51b22c1588e5a624bea17e9faa34b2dc4a",
"height": 528249,
"name": "BLOCK21E800",
"desc": null
},
{
"hash": "0000000000000000000fe6d521a187a5523d5cef6f6c178923ff82ffe5a0f372",
"height": 506734,
"name": "HURRICANE_1",
"desc": null
},
{
"hash": "0000000000000000004b27f9ee7ba33d6f048f684aaeb0eea4befd80f1701126",
"height": 501726,
"name": "NO_REWARD",
"desc": null
},
{
"hash": "000000000000000000cbeff0b533f8e1189cf09dfbebf57a8ebe349362811b80",
"height": 481823,
"name": "SEGWIT",
"desc": null
},
{
"hash": "0000000000000000012e6060980c6475a9a8e62a1bf44b76c5d51f707d54522c",
"height": 479808,
"name": "SEGWIT_LOCK",
"desc": null
},
{
"hash": "00000000000000000019f112ec0a9982926f1258cdcc558dd7c3b7e5dc7fa148",
"height": 478559,
"name": "BCC",
"desc": null
},
{
"hash": "0000000000000000015411ca4b35f7b48ecab015b14de5627b647e262ba0ec40",
"height": 477120,
"name": "BIP_91_LOCK",
"desc": null
},
{
"hash": "000000000000000002cce816c0ab2c5c269cb081896b7dcb34b8422d6b74ffa1",
"height": 420000,
"name": "HALVING_2",
"desc": null
},
{
"hash": "0000000000000001bc7156dd1183c87859b326affa3a5cdd157e809537f0b284",
"height": 270953,
"name": "WHALE201311",
"desc": null
},
{
"hash": "000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e",
"height": 210000,
"name": "HALVING_1",
"desc": null
},
{
"hash": "000000000000041c718cd2fa4270ab80c917bb94caa79c84b417b7924a867a68",
"height": 196883,
"name": "JOHN_CONWAY",
"desc": null
},
{
"hash": "00000000152340ca42227603908689183edc47355204e7aca59383b0aaac1fd8",
"height": 57043,
"name": "PIZZA",
"desc": null
},
{
"hash": "00000000132fbe8314fc571c0be60b31ccd461c9ee85f42bde8c6d160a9dacc0",
"height": 24835,
"name": "FIRST_USD_TX",
"desc": null
},
{
"hash": "000000000a73e64735a2b75c97ea674950a9018da1420d01328a918c9ff9852c",
"height": 5637,
"name": "TOPISTO",
"desc": null
},
{
"hash": "00000000a70ba4a405c67310757606dd955cf1a3a8e5c042335d78394ea6cb67",
"height": 3654,
"name": "DORMEUR_ORIGINE",
"desc": null
},
{
"hash": "000000008bf44a528a09d203203a6a97c165cf53a92ecc27aed0b49b86a19564",
"height": 1337,
"name": "LEET",
"desc": null
},
{
"hash": "00000000fc5b3c76f27f810ee775e480ae7fd604fd196b2d8da4257fcd39f4f9",
"height": 666,
"name": "LUCIFER",
"desc": null
},
{
"hash": "00000000d1145790a8694403d4063f323d499e655c83426834d4ce2f8dd4a2ee",
"height": 170,
"name": "FIRST_TX",
"desc": null
},
{
"hash": "00000000a2886c95400fd3b263b9920af80b118b28fee5d2a162a18e4d9d8b2f",
"height": 78,
"name": "HAL_FINLEY",
"desc": null
},
{
"hash": "00000000314e90489514c787d615cea50003af2023796ccdd085b6bcc1fa28f5",
"height": 42,
"name": "THE_ANSWER",
"desc": null
},
{
"hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
"height": 0,
"name": "GENESIS",
"desc": null
}
]

+ 75
- 0
methode2/lovecraft/draw.php 查看文件

@ -0,0 +1,75 @@
<?php
function DrawBlock($the_block, $vImage, $parametres)
{
// valeurs par défaut
$type = 1;
// Ces variables vont permettre de caler les lignes
// dans la zone de dessin en se laissant des marges
// en haut et en bas
$somme = 0;
$min =-1;
$max = 0;
$marge_x = 10;
$marge_y = 10;
$facteur_max = 2.5;
$alpha = 0;
// Détermine si on dessine les tx, les fees ou la récompense
if (isset($parametres['type'])) $type = $parametres['type'];
// Paramètres de dessin
if (isset($parametres['x'])) $x = $parametres['x'];
if (isset($parametres['y'])) $y = $parametres['y'];
if (isset($parametres['width'])) $width = $parametres['width'];
if (isset($parametres['height'])) $height = $parametres['height'];
if (isset($parametres['font_color'])) $vFgColor = $parametres['font_color'];
if (isset($parametres['background_color'])) $vBgColor = $parametres['background_color'];
if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB'];
if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB'];
// Remplir le fond
imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $vFgColor);
// Dégradé de 360 couleurs entre la couleur de dessin et le blanc
$nbColor = 360;
$vColor = getGDcolorGradientArray($vImage, $nbColor, $vBgRGB, $vFgRGB, $alpha);
// Récup des données
$data = blockchain::getTransactionData($the_block, $type);
$xc = $x + ($width / 2);
$yc = $y + ($height / 2);
$mini=$height/6.4;
$maxi=$height/3.2;
$angle=0;
$ppas=2000.0;
$pas=360.0/TX_HASH_LEN;
$pas /= $ppas;
for($i=0;$i<TX_HASH_LEN;$i++)
{
$valeur = hexdec($the_block->hash[$i]);
$r = $mini;
$r += ($maxi*(($valeur+1.0)/16.0));
$xi = $xc + $r*cos(deg2rad($angle));
$yi = $yc + $r*sin(deg2rad($angle));
for($ii=0;$ii<$ppas;$ii++)
{
$xi = $xc + $r*cos(deg2rad($angle));
$yi = $yc + $r*sin(deg2rad($angle));
imageline($vImage, $xc, $yc, $xi, $yi, $vColor[abs(floor(180-$angle))]->color);
$angle += $pas;
}
}
}
?>

+ 67
- 0
scripts/block2.sh 查看文件

@ -0,0 +1,67 @@
#!/bin/bash
lescript=`basename $0 .sh`
#
# TOOLS
#
function debug
{
if [ -f $FLAG_PATH/debug ]
then
echo $1
fi
}
#
# PARAMETRES PAR FICHIER FLAGS
#
if [ -f $FLAG_PATH/no_blocks ]
then
debug "No blocks"
fi
BLOCK=$1
if [ -z "$BLOCK" ]
then
BLOCK=`grep LAST $DATA_PATH/block_list.txt | awk '{print $2}'`
fi
echo $BLOCK
cd $APPS_PATH/info
infos=`php robot.php $BLOCK`
HEIGHT=`echo $infos | awk '{print $1}'`
TIMETS=`echo $infos | awk '{print $2}'`
NBTX=`echo $infos | awk '{print $3}'`
NONCE=`echo $infos | awk '{print $4}'`
PREV=`echo $infos | awk '{print $5}'`
#
# TEST DU FLAG
#
flag=$FLAG_PATH/bot_${lescript}_${BLOCK}.flag
if [ -f $flag ]
then
debug "${lescript}_${BLOCK} already done"
fi
touch $flag
LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | shuf`
cd $APPS_PATH/methode2
for METHODE in $LISTE_METHODE
do
if [ ! -d $DATA_PATH/$METHODE ]
then
mkdir -p $DATA_PATH/$METHODE
fi
echo $BLOCK $NAME $METHODE
if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ]
then
php robot.php $METHODE $BLOCK $((RANDOM % 6)) $2
cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png
cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
fi
done
cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/nonce/$BLOCK.png

+ 23
- 0
scripts/draw_all_empty_blocks.sh 查看文件

@ -0,0 +1,23 @@
#!/bin/bash
while IFS='' read -r line || [[ -n "$line" ]]; do
HASH=`echo $line | awk '{print $1}'`
HEIGHT=`echo $line | awk '{print $2}'`
if [ ! -f $DATA_PATH/json/$HASH.zip ]; then
cd $APPS_PATH/info
infos=`php robot.php $HASH`
NBTX=`echo $infos | awk '{print $3}'`
if [ $NBTX -eq 1 ]; then
echo draw bloc $HEIGHT
echo LAST $HASH $HEIGHT $NTX >> $DATA_PATH/emptybot/all_empty_blocks.txt
source $APPS_PATH/scripts/block2.sh $HASH
rm $DATA_PATH/json/$HASH.zip
fi
fi
done < $1
sort -n $DATA_PATH/emptybot/all_empty_blocks.txt

+ 96
- 0
scripts/triptyque.sh 查看文件

@ -0,0 +1,96 @@
#!/bin/bash
lescript=`basename $0 .sh`
#
# TOOLS
#
function debug
{
if [ -f $FLAG_PATH/debug ]
then
echo $1
fi
}
#
# PARAMETRES PAR FICHIER FLAGS
#
if [ -f $FLAG_PATH/no_blocks ]
then
debug "No blocks"
fi
BLOCK0=$1
if [ -z "$BLOCK" ]
then
BLOCK0=`grep LAST $DATA_PATH/block_list.txt | awk '{print $2}'`
fi
echo $BLOCK0
pushd $APPS_PATH/info
infos=`php robot.php $BLOCK0`
HEIGHT=`echo $infos | awk '{print $1}'`
TIMETS=`echo $infos | awk '{print $2}'`
NBTX=`echo $infos | awk '{print $3}'`
NONCE=`echo $infos | awk '{print $4}'`
PREV=`echo $infos | awk '{print $5}'`
popd
#
# TEST DU FLAG
#
flag=$FLAG_PATH/bot_${lescript}_${BLOCK0}.flag
if [ -f $flag ]
then
debug "${lescript}_${BLOCK0} already done"
fi
touch $flag
if [ -f $DATA_PATH/nonce/$BLOCK0.png ]
then
echo COMPUTE IMAGE FOR $BLOCK0
pushd $APPS_PATH >> /dev/null
./lancer2.sh block2 $BLOCK0
popd >> /dev/null
fi
echo $DATA_PATH/nonce/$BLOCK0.png
BLOCK1=$PREV
pushd $APPS_PATH/info >> /dev/null
infos=`php robot.php $BLOCK1`
HEIGHT=`echo $infos | awk '{print $1}'`
TIMETS=`echo $infos | awk '{print $2}'`
NBTX=`echo $infos | awk '{print $3}'`
NONCE=`echo $infos | awk '{print $4}'`
PREV=`echo $infos | awk '{print $5}'`
popd >> /dev/null
if [ -f $DATA_PATH/nonce/$BLOCK1.png ]
then
echo COMPUTE IMAGE FOR $BLOCK1
pushd $APPS_PATH >> /dev/null
./lancer2.sh block2 $BLOCK1
popd >> /dev/null
fi
echo $DATA_PATH/nonce/$BLOCK1.png
BLOCK2=$PREV
pushd $APPS_PATH/info >> /dev/null
infos=`php robot.php $BLOCK2`
HEIGHT=`echo $infos | awk '{print $1}'`
TIMETS=`echo $infos | awk '{print $2}'`
NBTX=`echo $infos | awk '{print $3}'`
NONCE=`echo $infos | awk '{print $4}'`
PREV=`echo $infos | awk '{print $5}'`
popd >> /dev/null
if [ -f $DATA_PATH/nonce/$BLOCK2.png ]
then
echo COMPUTE IMAGE FOR $BLOCK2
pushd $APPS_PATH >> /dev/null
./lancer2.sh block2 $BLOCK2
popd >> /dev/null
fi
echo $DATA_PATH/nonce/$BLOCK2.png
pushd $APPS_PATH/triptyque >> /dev/null
php robot.php $BLOCK0 $BLOCK1 $BLOCK2
popd >> /dev/null

+ 86
- 0
triptyque/robot.php 查看文件

@ -0,0 +1,86 @@
<?php
// ---
// --- La config globale
// ---
require_once '../global/inc/config.php';
// ---
// --- External dependances
// ---
require TOPISTO_PATH.'/ressources/vendor/autoload.php';
require_once '../global/inc/colors.php';
require_once '../global/inc/cubic.php';
// ---
// --- Internal dependances
// ---
require_once APP_PATH.'/blockchain/inc/block.php';
// ---
// --- Par défaut on cherche le dernier block
// --- Le cas échéant, on cherche block passé en argument
// ---
$block_hash0 = 'LAST';
if (isset($argv[1])) $block_hash0 = $argv[1];
$block_hash1 = 'LAST';
if (isset($argv[2])) $block_hash1 = $argv[2];
$block_hash2 = 'LAST';
if (isset($argv[3])) $block_hash2 = $argv[3];
$the_block = blockchain::getBlockWithHash($block_hash0);
if ($the_block === FALSE) die();
$taille=1;
$bandeau = 50;
$marge = 25;
$text_border = 20;
$width = GRAPH_WIDTH * $taille;
$height = GRAPH_HEIGHT * $taille;
$couleur = -1; // Au hasard
// Pour que l'image simple ait les proportions que l'image full
$width = $marge + ($width*2) + (2*$text_border);
$height = $marge + ($height*2);
// création d'une image plus haute pour inclure bandeaux haut et bas
$img_w = $width;
$img_h = ($height+(2*$bandeau));
$decal=5;
$y=0-($img_h/2);
$img = imagecreatetruecolor($img_w+10, ($img_h*2)-($decal*2));
// on met une couleur transparente sur le fond
//$white = imagecolorallocate($img, 254, 254, 254);
//imagecolortransparent($img, $white);
//imagefilledrectangle($img, 0, 0, $img_w, ($img_h*3)-($decal*2), $white);
$img_block=imagecreatefrompng(DATA_PATH.'/nonce/'.$block_hash0.'.png');
imagecopy($img, $img_block,5,$y,0,0,$img_w, $img_w);
imagedestroy($img_block);
$y+=$img_h - $decal;
$img_block=imagecreatefrompng(DATA_PATH.'/nonce/'.$block_hash1.'.png');
imagecopy($img, $img_block,5,$y,0,0,$img_w, $img_w);
imagedestroy($img_block);
$y+=$img_h - $decal;
$img_block=imagecreatefrompng(DATA_PATH.'/nonce/'.$block_hash2.'.png');
imagecopy($img, $img_block,5,$y,0,0,$img_w, $img_w);
imagedestroy($img_block);
// Draw a white rectangle
$black = imagecolorallocate($img, 0, 0, 0);
imagefilledrectangle($img, 0, 0, $img_w+10, 5, $black);
imagefilledrectangle($img, 0, ($img_h*2)-($decal*2)-5, $img_w+10, ($img_h*2)-($decal*2), $black);
imagepng($img, DATA_PATH.'/triptyque/'.$block_hash1.'.png');
imagedestroy($img);
?>

Loading…
取消
儲存