#!/bin/bash
flag=$TMP_PATH/blockchain_bot.flag

if [ -f $flag ];
then
  echo "blockchain_bot is already running !"
  exit 1
fi

touch $flag

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

# 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
