Skip to content

Instantly share code, notes, and snippets.

@thephez
Created August 23, 2022 21:19
Show Gist options
  • Save thephez/a0f29ecb4a739a8870be397c84592929 to your computer and use it in GitHub Desktop.
Save thephez/a0f29ecb4a739a8870be397c84592929 to your computer and use it in GitHub Desktop.
Get the height and hash of active quorums returned by "quorum list"
CLI_CMD='/Downloads/dashcore-18.0.1/bin/dash-cli'
CONF_FILE='/home/user/.dashcore/dash.conf'
DASH_CLI="${CLI_CMD} -conf=${CONF_FILE}"
#DASH_CLI="${CLI_CMD} -testnet" #-conf=${CONF_FILE}"
CURRENT_HEIGHT=$(${DASH_CLI} getblockcount)
echo "Current height: $CURRENT_HEIGHT"
function get_quorum_type_names() {
# dash-cli quorum list | jq -r keys[]
Q_TYPE_NAMES=$($DASH_CLI quorum list | jq -r keys[])
#printf "\nQuorum types found:\n$Q_TYPE_NAMES\n"
echo $Q_TYPE_NAMES
}
function get_quorum_list_by_type() {
for i in "$@"; do
#printf '%s\n' "$i"
echo "Quorum info for quorum: $i"
printf "\tHeight\tBlocks since previous\t\tHash\n"
# dash-cli quorum list | jq -r .llmq_100_67[]
Q_LIST=$($DASH_CLI quorum list | jq -r .$i[])
#echo "${Q_LIST}"
LAST_HEIGHT=$CURRENT_HEIGHT
for row in $(echo "${Q_LIST}"); do
#$DASH_CLI getblock ${row} | jq -r '{height}' | grep height
HEIGHT=$($DASH_CLI getblock ${row} | jq .height)
HASH=$($DASH_CLI getblock ${row} | jq -r .hash)
BLOCK_AGE=$(($CURRENT_HEIGHT - $HEIGHT))
BLOCK_SINCE_LAST=$(($LAST_HEIGHT - $HEIGHT))
#printf "\t$HEIGHT\t($BLOCK_AGE)\t$BLOCK_SINCE_LAST\t$HASH\n"
printf "\t$HEIGHT\t$BLOCK_SINCE_LAST\t$HASH\n"
LAST_HEIGHT=$HEIGHT
done
done
}
Q_TYPE_NAMES="$(get_quorum_type_names)"
#echo $Q_TYPE_NAMES
#get_quorum_list_by_type "llmq_400_85"
# List quorum info for all quorums
get_quorum_list_by_type $Q_TYPE_NAMES
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment