committed by
GitHub
2 changed files with 119 additions and 52 deletions
@ -1,42 +1,100 @@ |
|||
#!/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 |
|||
printf "\033[0;31mKMD - Possible fork!\033[0m Blocks $blocks < LongestChain $longest\n" |
|||
else |
|||
echo "KMD - Blocks $blocks = LongestChain $longest" |
|||
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 |
|||
printf "\033[0;31mCHIPS - Possible fork!\033[0m Blocks $blocks < Headers $longest\n" |
|||
else |
|||
echo "CHIPS - Blocks $blocks = Headers $longest" |
|||
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) |
|||
|
|||
blocks=$(komodo-cli -ac_name=${coin[0]} getinfo | jq .blocks) |
|||
longest=$(komodo-cli -ac_name=${coin[0]} getinfo | jq .longestchain) |
|||
|
|||
if ((blocks < longest)); then |
|||
forked=true |
|||
printf "\033[0;31m${coin[0]} - Possible fork!\033[0m Blocks $blocks < LongestChain $longest\n" |
|||
else |
|||
echo "${coin[0]} - Blocks $blocks = LongestChain $longest" |
|||
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 |
Loading…
Reference in new issue