Skip to content

Instantly share code, notes, and snippets.

@codeck
Last active April 4, 2016 03:59
Show Gist options
  • Save codeck/17862fa4279e28c40a8e0d89adf340b8 to your computer and use it in GitHub Desktop.
Save codeck/17862fa4279e28c40a8e0d89adf340b8 to your computer and use it in GitHub Desktop.
sia query util
siaq_block() {
curl -s -A "Sia-Agent" http://localhost:9980/explorer/blocks/$1
}
siaq_blkinfo() {
date --date=@$(siaq_block $1|jq .block.rawblock.timestamp)
siaq_block $latest | jq ".block.transactions[0].height, ($(date -u +%s)-.block.rawblock.timestamp)/60, .block.rawblock.nonce"
}
siaq_latest() {
local latest=$(curl -s -A "Sia-Agent" http://localhost:9980/consensus|jq .height)
siaq_blkinfo $latest
}
siaq() {
if [ -z "$1" ]
then
siaq_block $(curl -s -A "Sia-Agent" http://localhost:9980/consensus|jq .height) | jq .
else
curl -s -A "Sia-Agent" http://localhost:9980/explorer/hashes/$1|jq .
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment