-
Notifications
You must be signed in to change notification settings - Fork 27
/
wait_until_node_sync_gcp.sh
31 lines (26 loc) · 913 Bytes
/
wait_until_node_sync_gcp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
printf "\n[[[[[ wait_until_node_sync_gcp.sh ]]]]]\n\n"
printf "\n#### Wait until the new node server catches up ####\n\n"
SECONDS=0
loopCount=0
generate_post_data()
{
cat <<EOF
{"method":"$1","params":{"protoVer":"0.8.0"},"jsonrpc":"2.0","id":"1"}
EOF
}
while :
do
healthCheck=$(curl -m 20 -X GET -H "Content-Type: application/json" "http://localhost:8080/health_check")
printf "\nhealthCheck = ${healthCheck}\n"
if [[ "$healthCheck" = "true" ]]; then
printf "\nBlockchain Node server is synced & running!\n"
lastBlockNumber=$(curl -m 20 -X GET -H "Content-Type: application/json" "http://localhost:8080/last_block_number" | jq -r '.result')
printf "\nlastBlockNumber = ${lastBlockNumber}\n"
printf "\nTime it took to sync in seconds: $SECONDS\n"
break
fi
((loopCount++))
printf "\nLoop count: ${loopCount}\n"
sleep 20
done