Blockchain consensus protocol is a complicated beast. But it is the backbone of decentralization. Depending on the rules the certain blockchain adopted, it is usually the longest chain winning. However, in case of staking, it depends.
In cryptocurrency, this is made complicated by wallet updates.. Once wallet updates are made, multiple protocols of the same blockchain will co-exist. Multiple updates down the line and that becomes even worse. You get the drift.
The above is true with the cryptocurrency Aegeus, with ticker AEG. I just lost track of how many updates there are (I wasn't an early adopter), but the current wallet version is V-3.0.0 (Protocol 70818). I have experienced several times where my wallet has gone haywire, and that in turn gave me orphan blocks.
This script is the solution I put in place to get notified of the occurrence, and at the same time re-start the wallet so that I don't have to do anything. The script is based on the screenshots above.
It assumes the following things:
- The explorer contains the correct copy of the blockchain (HINT: It usually is!)
- The wallet has the ability to re-correct itself through the blockchain consensus protocol
- You are running the hot wallet in a Linux environment
The logic is simple: If the local block hash is the same as that of the explorer block hash for the same height, then I'm on the right chain. If not, restart the wallet.
This script also makes use of the push notifications of wallet events to your mobile phone. If you are not into telegram and want another alternative, here's the same push notifications but with PushBullet.
I run this script regularly with cron.. It is set to run every 15 minutes. With this configuration, no significant load increases have occurred in the VPS. So I left it to run at that frequency.
The script can be modified to adapt to other cryptocurrencies. Just need to modify the service, the CLI commands and the URL of the explorer.
(screencaps are mine)
If you happen to find this script helpful, send me an upvote, or resteem this post, or buy me beer by these wallets. Thanks in advance.
- #Bitcoin (BTC) - 3Kyjg1Wj1PNGN3KhiRprxYvvQpdjC5kT3k
- #Etherium (ETH) - 0x5F168F895C63ccC5FbEf921047bc2b63f6780c3F
- #Aegeus (AEG) - AVjd8s5fC17bE49QpLjBnve29kFiEGeGG6
Thanks! (vote for them as witness!)