You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

100 lines
3.2 KiB

#!/bin/bash
#You can modify this list of ACs to exclude or comment out the line to show all
ignoreacs=('VOTE2018' 'BEER' 'PIZZA')
#how far ahead or behind before being marked as a fork
variance=3
source coinlist
forked=false
remotecheck=$(curl -Ssf https://komodostats.com/api/notary/summary.json)
remotecheck2=$(curl -Ssf https://dexstats.info/api/explorerstatus.php)
format="%-8s %8s %8s %8s %8s\n"
redformat="\033[0;31m$format\033[0m"
printf "$format" "-ASSET-" "-BLOCKS-" "-LONG-" "-RMT1-" "-RMT2-"
#KMD
blocks=$(komodo-cli getinfo | jq .blocks)
longest=$(komodo-cli getinfo | jq .longestchain)
remoteblocks=$(echo $remotecheck | jq '.[] | select(.ac_name=="KMD") | .blocks')
remoteblocks2=$(echo $remotecheck2 | jq '.status[] | select(.chain=="KMD") | .height | tonumber')
diff1=$((blocks-remoteblocks))
diff2=$((blocks-remoteblocks2))
thisformat=$format
if ((blocks < longest)); then
forked=true
thisformat=$redformat
fi
if (( diff1 < variance * -1 )) || (( diff1 > variance )); then
forked=true
thisformat=$redformat
fi
if (( diff2 < variance * -1 )) || (( diff2 > variance )); then
forked=true
thisformat=$redformat
fi
printf "$thisformat" "KMD" "$blocks" "$longest" "$remoteblocks" "$remoteblocks2"
#CHIPS
blocks=$(chips-cli getinfo | jq .blocks)
longest=$(chips-cli getinfo | jq .headers)
remoteblocks=$(echo $remotecheck | jq '.[] | select(.ac_name=="CHIPS") | .blocks')
diff1=$((blocks-remoteblocks))
thisformat=$format
if ((blocks < longest)); then
forked=true
thisformat=$redformat
fi
if (( diff1 < variance * -1 )) || (( diff1 > variance )); then
forked=true
thisformat=$redformat
fi
printf "$thisformat" "CHIPS" "$blocks" "$longest" "$remoteblocks"
#GAME
blocks=$(gamecredits-cli getinfo | jq .blocks)
remoteblocks=$(echo $remotecheck | jq '.[] | select(.ac_name=="GAME") | .blocks')
diff1=$((blocks-remoteblocks))
thisformat=$format
if (( diff1 < variance * -1 )) || (( diff1 > variance )); then
forked=true
thisformat=$redformat
fi
printf "$thisformat" "GAME" "$blocks" " " "$remoteblocks"
for coins in "${coinlist[@]}"; do
coin=($coins)
if [[ ! ${ignoreacs[*]} =~ ${coin[0]} ]]; then
blocks=$(komodo-cli -ac_name=${coin[0]} getinfo | jq .blocks)
longest=$(komodo-cli -ac_name=${coin[0]} getinfo | jq .longestchain)
remoteblocks=$(echo $remotecheck | jq --arg acname ${coin[0]} '.[] | select(.ac_name==$acname) | .blocks')
remoteblocks2=$(echo $remotecheck2 | jq --arg acname ${coin[0]} '.status[] | select(.chain==$acname) | .height | tonumber')
diff1=$((blocks-remoteblocks))
diff2=$((blocks-remoteblocks2))
thisformat=$format
if ((blocks < longest)); then
forked=true
thisformat=$redformat
fi
if (( diff1 < variance * -1 )) || (( diff1 > variance )); then
forked=true
thisformat=$redformat
fi
if (( diff2 < variance * -1 )) || (( diff2 > variance )); then
forked=true
thisformat=$redformat
fi
printf "$thisformat" "${coin[0]}" "$blocks" "$longest" "$remoteblocks" "$remoteblocks2"
fi
done
if [ "$forked" = false ]; then
printf "\033[0;32mAll coins are fine\033[0m\n"
else
printf "\033[0;31mPossible fork!\033[0m\n"
fi