Skip to content

Instantly share code, notes, and snippets.

@pbostrom
Last active February 22, 2019 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbostrom/5ea123b8128a881972a0b9cb371df1b8 to your computer and use it in GitHub Desktop.
Save pbostrom/5ea123b8128a881972a0b9cb371df1b8 to your computer and use it in GitHub Desktop.
block_age() {
bt=$(date -d "$1" +%s)
now=$(date +%s)
echo $(( $now - $bt ))
}
status=$(curl -s http://localhost:46657/status)
addr=$(echo $status | jq -r ".result.validator_info.address")
lbh=$(echo $status | jq -r ".result.sync_info.latest_block_height")
lbt=$(echo $status | jq -r ".result.sync_info.latest_block_time")
ba=$(block_age $lbt)
echo "Latest block height: $lbh"
echo "Latest block age: $ba seconds"
echo "Validator address: $addr"
precommit=$(curl -s http://localhost:46657/block?height=$lbh | jq -r ".result.block.last_commit.precommits | .[] | select(.validator_address==\"$addr\")")
echo "Precommit: $precommit"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment