forked from Cardinal-Cryptography/aleph-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_finalization.sh
More file actions
executable file
·33 lines (27 loc) · 1.09 KB
/
check_finalization.sh
File metadata and controls
executable file
·33 lines (27 loc) · 1.09 KB
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
32
33
#!/bin/bash
RPC_HOST=127.0.0.1
RPC_PORT=9933
LAST_FINALIZED=""
VALIDATOR=damian
while [[ "$LAST_FINALIZED" =~ "0x0" ]] || [[ -z "$LAST_FINALIZED" ]]; do
block_hash=$(docker run --network container:$VALIDATOR appropriate/curl:latest \
-H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "chain_getFinalizedHead"}' http://$RPC_HOST:$RPC_PORT | jq '.result')
ret_val=$?
if [ $ret_val -ne 0 ]; then
echo "failed calling the `chain_getFinalizedHead` method" >&2
continue
fi
finalized_block=$(docker run --network container:$VALIDATOR appropriate/curl:latest \
-H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "chain_getBlock", "params": ['$block_hash']}' http://$RPC_HOST:$RPC_PORT | jq '.result.block.header.number')
ret_val=$?
if [ $ret_val -ne 0 ]; then
echo "failed calling the `chain_getBlock` method" >&2
continue
else
LAST_FINALIZED=$finalized_block
echo "Last finalized block number: $LAST_FINALIZED"
fi
done
exit $?