Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
tezos-reward-gaps.sh: show time between baking/endorsing to help schedule node maintenance
#!/bin/bash
# This script will only show time gaps between future endorsing slots.
# You need to install JQ: https://stedolan.github.io/jq/
# Enter your path to tezos-client here, without a trailing slash
tc="/home/tezos/tezos/tezos-client"
delegate="tz1______________"
timezone="America/New_York"
# This gives you cleaner output. Comment it out then log off/log in to see the warning.
export TEZOS_CLIENT_UNSAFE_DISABLE_DISCLAIMER=Y
cycle=$1
nodestatus=$(ps -fU tezos | grep "[t]ezos-node run")
echo "$nodestatus" | grep -qi "tezos-node run"
if [ $? -eq 0 ];then
endorsing_times=$($tc rpc get "/chains/main/blocks/head/helpers/endorsing_rights?delegate=$delegate&cycle=$1" | jq -r '.[].estimated_time' | sed '/null/d' | sed '/^\s*$/d')
arr=($endorsing_times)
arraylength=${#arr[@]}
# Calculates the difference between each event
for ((index=1; index < ${arraylength}; index++))
do
current=$(dateutils.dconv ${arr[index]} --from-zone UTC --zone "$timezone")
previous=$(dateutils.dconv ${arr[index-1]} --from-zone UTC --zone "$timezone")
diff=$(dateutils.ddiff $previous $current -f '%Hh %Mm %Ss')
echo $diff" between $previous & $current"
done
elif [[ -n "$flag" ]];then
echo "Node Stopped"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.