#!/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

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

rm -f $DATA_PATH/block_list.tmp
rm -f $flag
