From 3c7acc8443547d10409c4ec80d7d248220c4a7f6 Mon Sep 17 00:00:00 2001 From: MEUNIER Thibaud Date: Sat, 29 Dec 2018 09:56:36 +0100 Subject: [PATCH] hashes tient compte du cache --- blockchain/cache.php | 8 +++----- blockchain/inc/block.php | 5 +++-- blockchain/robot.sh | 10 +++++++++- global/inc/config.php | 2 +- methode/hashes/robot.sh | 24 +++++++++--------------- methode2/circle/draw.php | 1 + methode2/circle_line/draw.php | 1 + methode2/circles/draw.php | 11 ++++++----- scripts/blocks2.sh | 24 +++++++++++++++--------- scripts/tweet.sh | 2 +- twitter/twitterbot/robot.php | 2 +- twitter/twitterbot/robot.sh | 5 +++-- 12 files changed, 53 insertions(+), 42 deletions(-) diff --git a/blockchain/cache.php b/blockchain/cache.php index 8e97930..247a8fd 100644 --- a/blockchain/cache.php +++ b/blockchain/cache.php @@ -27,23 +27,21 @@ $the_block = blockchain::getSpecialBlock($block_hash); if ($the_block === FALSE) die(); // --- -// --- On en recherche 3 sur approximativement 6 heures (36 blocks) +// --- On en recherche 6 sur approximativement 6 heures (36 blocks) // --- -$max = 3; +$max = 6; $max2 = 36; while(($max > 0)&&($max2 > 0)) { $block_hash = $the_block->prev_block; if (!file_exists(DATA_PATH.'/json/'.$block_hash.'.zip')) - { - $max--; 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--; $max2--; } diff --git a/blockchain/inc/block.php b/blockchain/inc/block.php index b4ac244..f9b73ca 100644 --- a/blockchain/inc/block.php +++ b/blockchain/inc/block.php @@ -27,14 +27,15 @@ class blockchain 'TOPISTO' => '000000000a73e64735a2b75c97ea674950a9018da1420d01328a918c9ff9852c', 'PIZZA' => '00000000006de085dadb3ec413ef074022fe781121b467e98960280dd246bb00', 'HALVING_1' => '000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e', + 'WHALE201311' => '0000000000000001bc7156dd1183c87859b326affa3a5cdd157e809537f0b284', 'HALVING_2' => '000000000000000002cce816c0ab2c5c269cb081896b7dcb34b8422d6b74ffa1', 'BIP_91_LOCK' => '0000000000000000015411ca4b35f7b48ecab015b14de5627b647e262ba0ec40', 'BCC' => '00000000000000000019f112ec0a9982926f1258cdcc558dd7c3b7e5dc7fa148', 'SEGWIT_LOCK' => '0000000000000000012e6060980c6475a9a8e62a1bf44b76c5d51f707d54522c', 'SEGWIT' => '000000000000000000cbeff0b533f8e1189cf09dfbebf57a8ebe349362811b80', 'HURRICANE_1' => '0000000000000000000fe6d521a187a5523d5cef6f6c178923ff82ffe5a0f372', - 'WHALE201810' => '0000000000000000000f9f2dadfb8f312572183272802cbfcc4ff95b4ee6777d', - 'BLOCK21E800' => '00000000000000000021e800c1e8df51b22c1588e5a624bea17e9faa34b2dc4a' + 'BLOCK21E800' => '00000000000000000021e800c1e8df51b22c1588e5a624bea17e9faa34b2dc4a', + 'WHALE201810' => '0000000000000000000f9f2dadfb8f312572183272802cbfcc4ff95b4ee6777d' ); // --- diff --git a/blockchain/robot.sh b/blockchain/robot.sh index c22d87e..efe6114 100755 --- a/blockchain/robot.sh +++ b/blockchain/robot.sh @@ -15,9 +15,17 @@ rm -f $DATA_PATH/block_list.txt php cache.php >> $DATA_PATH/block_list.txt -for BLOCK in GENESIS THE_ANSWER LUCIFER LEET TOPISTO PIZZA HALVING_1 HALVING_2 BIP_91_LOCK BCC SEGWIT_LOCK SEGWIT HURRICANE_1 WHALE201810 BLOCK21E800 LAST +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" + +for BLOCK in $LISTBLOCKS do php robot.php $BLOCK >> $DATA_PATH/block_list.txt done +cat $DATA_PATH/block_list.txt + rm -f $flag diff --git a/global/inc/config.php b/global/inc/config.php index 73c0518..f5edaaa 100644 --- a/global/inc/config.php +++ b/global/inc/config.php @@ -15,7 +15,7 @@ define('RESS_PATH', TOPISTO_PATH.'/ressources'); define('TMP_PATH', TOPISTO_PATH.'/tmp'); define('DATA_PATH', TOPISTO_PATH.'/data'); -define('BIG_PATH', TOPISTO_PATH.'/big'); +define('BIG_PATH', TOPISTO_PATH.'/big'); define('SOLD_PATH', TOPISTO_PATH.'/sold'); define('OFFLINE_PATH', RESS_PATH.'/offline'); diff --git a/methode/hashes/robot.sh b/methode/hashes/robot.sh index 573f589..17aec2f 100755 --- a/methode/hashes/robot.sh +++ b/methode/hashes/robot.sh @@ -11,24 +11,18 @@ fi touch $flag cd $APPS_PATH/methode/$METHODE -for BLOCK in `grep LAST $DATA_PATH/block_list.txt | awk '{print $2}'` +for TYPE in CACHE LAST do - if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ] - then + for BLOCK in `grep $TYPE $DATA_PATH/block_list.txt | awk '{print $2}'` + do BLOCK_HEIGHT=`grep $BLOCK $DATA_PATH/block_list.txt | awk '{print $3}'` - php robot.php $BLOCK $((RANDOM % 6)) - - echo $BLOCK_HEIGHT $BLOCK >> $DATA_PATH/hashes2hashes/liste.txt - fi - - BNAME=`grep $BLOCK $DATA_PATH/block_list.txt | awk '{print $1}'` - if [ "$BNAME" == "LAST" ] - then - touch $DATA_PATH/$METHODE/$BLOCK.png - else - touch -t $date $DATA_PATH/$METHODE/$BLOCK.png - fi + BNAME=`grep $BLOCK $DATA_PATH/block_list.txt | awk '{print $1}'` + if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ] + then + php robot.php $BLOCK $((RANDOM % 6)) + fi + done done rm -f $flag diff --git a/methode2/circle/draw.php b/methode2/circle/draw.php index 5c0efb7..9fd205b 100644 --- a/methode2/circle/draw.php +++ b/methode2/circle/draw.php @@ -14,6 +14,7 @@ function DrawBlock($the_block, $vImage, $parametres) $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']; diff --git a/methode2/circle_line/draw.php b/methode2/circle_line/draw.php index d928b0a..b165e19 100644 --- a/methode2/circle_line/draw.php +++ b/methode2/circle_line/draw.php @@ -14,6 +14,7 @@ function DrawBlock($the_block, $vImage, $parametres) $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']; diff --git a/methode2/circles/draw.php b/methode2/circles/draw.php index e3a9e86..b21e90a 100644 --- a/methode2/circles/draw.php +++ b/methode2/circles/draw.php @@ -8,12 +8,13 @@ function DrawBlock($the_block, $vImage, $parametres) // 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; + $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']; diff --git a/scripts/blocks2.sh b/scripts/blocks2.sh index cce9566..8b3a99d 100755 --- a/scripts/blocks2.sh +++ b/scripts/blocks2.sh @@ -1,5 +1,5 @@ #!/bin/bash -lescript=`basename $0 .sh` +lescript=blocks2 # # TOOLS @@ -39,6 +39,8 @@ then fi while IFS='' read -r line || [[ -n "$line" ]]; do + + NAME=`echo $line | awk '{print $1}'` BLOCK=`echo $line | awk '{print $2}'` HEIGHT=`echo $line | awk '{print $3}'` NBTX=`echo $line | awk '{print $4}'` @@ -57,9 +59,8 @@ while IFS='' read -r line || [[ -n "$line" ]]; do # # CHOISIR UNE METHODE2 AU HASARD # - for METHODE in `ls $APPS_PATH/methode2 | grep -v robot | shuf` + for METHODE in `ls $APPS_PATH/methode2 | grep -v robot | shuf | head -n 1` do - echo $METHODE if [ ! -d $DATA_PATH/$METHODE ] then mkdir -p $DATA_PATH/$METHODE @@ -69,14 +70,19 @@ while IFS='' read -r line || [[ -n "$line" ]]; do then cd $APPS_PATH/methode2 php robot.php $METHODE $BLOCK $((RANDOM % 6)) $2 - if [ "$2" == "" ]; - then - rm -f $DATA_PATH/hasard/$BLOCK.png - ln $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png - ln $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png - fi + cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png fi done + + if [ ! -f $DATA_PATH/hasard/$BLOCK.png ] + then + cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png + fi + + touch $DATA_PATH/hasard/$BLOCK.png + + rm -f $flag + done < $DATA_PATH/block_list.txt # diff --git a/scripts/tweet.sh b/scripts/tweet.sh index 93ad022..94725c9 100755 --- a/scripts/tweet.sh +++ b/scripts/tweet.sh @@ -56,7 +56,7 @@ fi # # TWEET # -TWEET=30 +TWEET=8 if [ $((MINUTE % $TWEET)) -eq 0 ] then debug "send a TWEET" diff --git a/twitter/twitterbot/robot.php b/twitter/twitterbot/robot.php index 9f4fa5a..06825dc 100644 --- a/twitter/twitterbot/robot.php +++ b/twitter/twitterbot/robot.php @@ -69,7 +69,7 @@ if (file_exists($image_file)) // --- // --- Tweet // --- - $tweet = "#bitcoin #blockchain 's".PHP_EOL; + $tweet = "#computerart : #bitcoin #blockchain 's".PHP_EOL; $tweet .= $argv[2]." Block, Height : ".$the_block->height.PHP_EOL; $tweet .= "[ See more on www.topisto.net ]"; $success = twitter::tweet($tweet, $image_file); diff --git a/twitter/twitterbot/robot.sh b/twitter/twitterbot/robot.sh index ba1ab97..a7c7081 100755 --- a/twitter/twitterbot/robot.sh +++ b/twitter/twitterbot/robot.sh @@ -21,8 +21,9 @@ do then php robot.php $BLOCK CONFIRMED hashes2hashes touch $DATA_PATH/twitterbot/assemblage_$BLOCK - rm -f $flag - exit 0 + #rm -f $flag + #exit 0 + sleep 30 fi done