Check EOS Node Status - Python Script

in eosio •  7 months ago

Anyone who has been on the launch of a new Blockchain will know that the process can be quite stressful. I have personally been maintaining a testnet node for EOS Argentina and the multiple chain forks inspired me to build this little script that checks your node´s Blockchain head number and compare it to another node, ideally to one that you know is on the main chain, but you could also compare two of you own nodes to check if they are on the same head_block_num.

Our node is in the jungle testnet so I compare my block with @cryptolions node since they are the BPs who maintain this chain and are usually in the latest block. This is what I initially came up with (bare in mind I have had very little sleep in the last few days):

import urllib.request
import json

url = urllib.request.urlopen('')
arg =
eosarg  = json.loads(arg)

eosargentina = (eosarg["head_block_num"])
eosargentina1 = str(eosargentina)
print ("eosargentina node is at block " + eosargentina1)

url = urllib.request.urlopen('')
lion =
cryptolions  = json.loads(lion)

lionblock = (cryptolions["head_block_num"])
lionblock1 = str(lionblock)
print ("cryptolions node is at block " + lionblock1)

if eosargentina == lionblock:
        print ("is all good")
else :
        print ("we are forked!!!!")

A good friend of mine cleaned this code a little and made it more readable and scalable, I recommend you use his version:

import requests as r
import json

def get_head_block_from(url):
    res = json.loads(r.get('{0}/v1/chain/get_info'.format(url)).text)
    return int(res["head_block_num"])

eosargentina = get_head_block_from("")
cryptolions  = get_head_block_from("")

if eosargentina == cryptolions:
    print ("is all good")
else :
    print ("we are forked!!!!")
    print (" - eosargentina : {0}".format(eosargentina))
    print (" - cryptolions  : {0}".format(cryptolions))

I hope this script can help others too, it certainly saved me a lot of time. I will be publishing more tools as we make them.

Until the next time.

see this code in gist

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Great post sir.
You are so much talented person on steemit. 😊💙
I completely agree with you.

Python is very useful script.

I appreciate your work.
Very informative post.
Very well articulated.

Thanks @chitty sir for sharing this post.

Upvoted + resteemed your post.

To get this news delivered to us. Thank you

Even i want learn about coding blockchain , I got good knowledge of Java . Let me know from where to begin .

wow nice great work bro........

python is one of the the most important apps for do programe.......

keep it bro

Thank you so much for sharing, this is very useful for me, may God avenge the goodness of your heart, sharing that is wonderful

Helpful post for the steemit community. thanks a lot for sharing with us......@chitty

Great work @chitty, phython and many other softwares like c++, dev c++, apachetom cat are best for programing. Thanks for sharing this helpful program with your steemit friends.

You got a 26.67% upvote from @dailyupvotes courtesy of @hcf27!

Please upvote this comment to support the service.

Si es muy estresante el lanzamiento del nuevo Blockchain. pero bueno el skrip me funciona a la perfecion gracias :D