priorité nonce
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
// ---
|
||||
// --- La config globale
|
||||
// ---
|
||||
require_once '../global/inc/config.php';
|
||||
|
||||
// ---
|
||||
// --- External dependances
|
||||
// ---
|
||||
require TOPISTO_PATH.'/ressources/vendor/autoload.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_hash = 'LAST';
|
||||
if (isset($argv[1])) $block_hash = $argv[1];
|
||||
|
||||
$the_block = blockchain::getBlockWithHash($block_hash);
|
||||
if ($the_block === FALSE) die();
|
||||
|
||||
echo $the_block->nonce;
|
||||
|
||||
?>
|
||||
+23
-7
@@ -1,5 +1,6 @@
|
||||
#!/bin/bash
|
||||
lescript=blocks2
|
||||
lescript=`basename $0 .sh`
|
||||
flag=$TMP_PATH/bot_$lescript.flag
|
||||
|
||||
#
|
||||
# TOOLS
|
||||
@@ -56,16 +57,26 @@ while IFS='' read -r line || [[ -n "$line" ]]; do
|
||||
fi
|
||||
touch $flag
|
||||
|
||||
if [ ! -f $DATA_PATH/nonce/$BLOCK.png ]
|
||||
then
|
||||
#
|
||||
# Si c'est la première fois que l'on dessine le block
|
||||
# On choisit la méthode qui découle du nonce
|
||||
#
|
||||
cd $APPS_PATH/nonce
|
||||
nbmethodes=`cat $DATA_PATH/nonce_methods_list.txt | wc -l`
|
||||
lenonce=`php robot.php $BLOCK`
|
||||
lamethode=$((lenonce % nbmethodes))
|
||||
if [ $lamethode -eq 0 ]
|
||||
then
|
||||
lamethode=$nbmethodes
|
||||
fi
|
||||
LISTE_METHODE=`cat $DATA_PATH/nonce_methods_list.txt | head -n $lamethode | tail -1`
|
||||
else
|
||||
#
|
||||
# CHOISIR UNE METHODE2 AU HASARD
|
||||
#
|
||||
# LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | shuf`
|
||||
# LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | shuf | head -n 1`
|
||||
# en rajoutant le head, on ne fait qu'un seul dessin
|
||||
LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | shuf | head -n 1`
|
||||
if [ $HEIGHT -eq 1 ]
|
||||
then
|
||||
LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v treemap | grep -v robot | shuf | head -n 1`
|
||||
fi
|
||||
|
||||
cd $APPS_PATH/methode2
|
||||
@@ -89,6 +100,11 @@ while IFS='' read -r line || [[ -n "$line" ]]; do
|
||||
cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
|
||||
fi
|
||||
|
||||
if [ ! -f $DATA_PATH/nonce/$BLOCK.png ]
|
||||
then
|
||||
cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/nonce/$BLOCK.png
|
||||
fi
|
||||
|
||||
rm -f $flag
|
||||
|
||||
done < $DATA_PATH/block_list.txt
|
||||
|
||||
@@ -13,8 +13,8 @@ if [ "$#" -eq "0" ]
|
||||
then
|
||||
if [ -d $DATA_PATH ]
|
||||
then
|
||||
find $DATA_PATH -mtime +1 -type f -name *.png -exec rm -f {} \;
|
||||
find $DATA_PATH -mtime +1 -type f -name *.zip -exec rm -f {} \;
|
||||
find $DATA_PATH -mtime +3 -type f -name *.png -exec rm -f {} \;
|
||||
find $DATA_PATH -mtime +3 -type f -name *.zip -exec rm -f {} \;
|
||||
|
||||
find $TMP_PATH -mtime +3 -type f -name *.flag -exec rm -f {} \;
|
||||
fi
|
||||
|
||||
@@ -72,6 +72,7 @@ while IFS='' read -r line || [[ -n "$line" ]]; do
|
||||
echo $BLOCK $NAME $METHODE
|
||||
if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ]
|
||||
then
|
||||
echo Drawing $BLOCK $METHODE
|
||||
php robot.php $METHODE $BLOCK $((RANDOM % 6)) $2
|
||||
cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png
|
||||
fi
|
||||
|
||||
Executable
+69
@@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
lescript=`basename $0 .sh`
|
||||
flag=$TMP_PATH/bot_$lescript.flag
|
||||
|
||||
#
|
||||
# TOOLS
|
||||
#
|
||||
function debug
|
||||
{
|
||||
if [ -f $FLAG_PATH/debug ]
|
||||
then
|
||||
echo $1
|
||||
fi
|
||||
}
|
||||
|
||||
function sortie
|
||||
{
|
||||
if [ -f $flag ]
|
||||
then
|
||||
rm -f $flag
|
||||
fi
|
||||
exit $1
|
||||
}
|
||||
|
||||
function succes
|
||||
{
|
||||
debug "SUCCES"
|
||||
sortie 0
|
||||
}
|
||||
|
||||
function echec
|
||||
{
|
||||
debug "ECHEC"
|
||||
sortie 1
|
||||
}
|
||||
|
||||
#
|
||||
# TEST DU FLAG
|
||||
#
|
||||
if [ -f $flag ]
|
||||
then
|
||||
debug "$0 is already running !"
|
||||
exit 1
|
||||
fi
|
||||
touch $flag
|
||||
|
||||
#
|
||||
# DO IT !
|
||||
#
|
||||
while IFS='' read -r line || [[ -n "$line" ]]; do
|
||||
#
|
||||
# On choisit la méthode qui découle du nonce
|
||||
#
|
||||
cd $APPS_PATH/nonce
|
||||
nbmethodes=`ls $APPS_PATH/methode2 | grep -v robot | wc -l`
|
||||
lenonce=`php robot.php $BLOCK`
|
||||
lamethode=$((lenonce%nbmethodes))
|
||||
[ $lamethode -eq 0 ] ; lamethode=$nbmethodes
|
||||
METHODE=`ls $APPS_PATH/methode2 | grep -v robot | head -n $lamethode`
|
||||
if [ -f $DATA_PATH/$METHODE/$BLOCK.png ]
|
||||
then
|
||||
cp $DATA_PATH/$METHODE/$BLOCK.png $DATA_PATH/nonce/$BLOCK.png
|
||||
fi
|
||||
done < $DATA_PATH/block_list.txt
|
||||
|
||||
#
|
||||
# SORTIE AVEC SUCCES
|
||||
#
|
||||
succes
|
||||
Reference in New Issue
Block a user