github.com/evdatsion/aphelion-dpos-bft@v0.32.1/test/p2p/kill_all/check_peers.sh (about) 1 #! /bin/bash 2 set -eu 3 4 NUM_OF_PEERS=$1 5 6 # how many attempts for each peer to catch up by height 7 MAX_ATTEMPTS_TO_CATCH_UP=120 8 9 echo "Waiting for nodes to come online" 10 set +e 11 for i in $(seq 1 "$NUM_OF_PEERS"); do 12 addr=$(test/p2p/ip.sh "$i"):26657 13 curl -s "$addr/status" > /dev/null 14 ERR=$? 15 while [ "$ERR" != 0 ]; do 16 sleep 1 17 curl -s "$addr/status" > /dev/null 18 ERR=$? 19 done 20 echo "... node $i is up" 21 done 22 set -e 23 24 # get the first peer's height 25 addr=$(test/p2p/ip.sh 1):26657 26 h1=$(curl -s "$addr/status" | jq .result.sync_info.latest_block_height | sed -e "s/^\"\(.*\)\"$/\1/g") 27 echo "1st peer is on height $h1" 28 29 echo "Waiting until other peers reporting a height higher than the 1st one" 30 for i in $(seq 2 "$NUM_OF_PEERS"); do 31 attempt=1 32 hi=0 33 34 while [[ $hi -le $h1 ]] ; do 35 addr=$(test/p2p/ip.sh "$i"):26657 36 hi=$(curl -s "$addr/status" | jq .result.sync_info.latest_block_height | sed -e "s/^\"\(.*\)\"$/\1/g") 37 38 echo "... peer $i is on height $hi" 39 40 ((attempt++)) 41 if [ "$attempt" -ge $MAX_ATTEMPTS_TO_CATCH_UP ] ; then 42 echo "$attempt unsuccessful attempts were made to catch up" 43 curl -s "$addr/dump_consensus_state" | jq .result 44 exit 1 45 fi 46 47 sleep 1 48 done 49 done