Find inactive witnesses you vote for - with python

11개월 전

witnesses.png
Screenshot: https://steemd.com/witnesses

Inspired by @gadrian's recent post "Had a look at my approved witness list [...]" I decided to take a look to my own witness votes. One aspect here was: do I vote for inactive witnesses. While there's nothing wrong with voting for (permanently) inactive witnesses, it just doesn't benefit anybody. There are probably a couple of tools already out there to get the same information, but I'll take the occasion to show how this can be done with beem/python:

Steps involved:

  • get a list of all witnesses an account votes for
  • get the witness details of those
  • check if they have set the 'disabled' signing key STM1111111111111111111111111111111114T1Anm
  • check for how long they haven't been scheduled a block

Code:

import sys
from beem import Steem
from beem.blockchain import Blockchain
from beem.account import Account
from beem.witness import GetWitnesses
from prettytable import PrettyTable
from datetime import timedelta, datetime

s = Steem(use_condenser=True)
a = Account(sys.argv[1], steem_instance=s)
pt = PrettyTable(['Witness', 'inactive since'])
head = Blockchain(mode='head', steem_instance=s).get_current_block_num()

for w in GetWitnesses(a['witness_votes'], steem_instance=s):
    if w.is_active is True:
        inactive_date = "active"
    else:
        inactive = timedelta(seconds=(head - w['last_aslot']) * 3)
        inactive_date = (datetime.utcnow() - inactive).date()
    pt.add_row([w['owner'], inactive_date])

print(pt)

Remarks:

  • The list of voted witnesses is only available via the condenser API (for whatever reason?!) - this is why it needs a dedicated Steem() instance.
  • The last scheduled block is given as a block number. In order to get the time since then, I take the difference in blocks to the current head block and calculate the time with the Steem block time (3s).

Save the snippet above as a .py file and run it with python (assuming beem is installed):

python [filename].py [your_account]

Here's the result for me


inactive_witnesses.png

There are two candidates who shut down their witnesses and were last scheduled around half a year ago. I'll probably unvote those.
I realize I have quite a couple of free slots - not that my stake moves the ranks, but time to have a look for new witnesses to vote. Every vote counts.

Feel free to leave a comment if you want to have your witness votes checked, I can run the same script for you.

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!
STEEMKR.COM IS SPONSORED BY
ADVERTISEMENT
Sort Order:  trending

!witness-vote-check emrebeyler

·

@emrebeyler, these witnesses you have voted for have retired (or are running a zombie server):

provenezuela


You have 0 witness votes left to use.

You are voting for: actifit, adsactly-witness, ausbitbank, blockbrothers, bobinson, c0ff33a, crowdwitness, danielsaori, dpoll.witness, emrebeyler, fyrst-witness, guiltyparties, helpie, holger80, isnochys, kevinwong, lux-witness, mahdiyari, mysia, neoxian, nextgencrypto, ocd-witness, pharesim, provenezuela, ro-witness, steempress, themarkymark, therealwolf, untersatz, yehey.


Powered by witness untersatz!

!witness-vote-check crokkon 😜

·

@crokkon, these witnesses you have voted for have retired (or are running a zombie server):

krnel, noblewitness


You have 12 witness votes left to use.

You are voting for: actifit, arcange, busy.witness, c0ff33a, c-squared, curie, dpoll.witness, emrebeyler, holger80, krnel, lukestokes.mhth, noblewitness, ocd-witness, patrice, qurator, stem.witness, therealwolf, wise-team.


Powered by witness untersatz!

·
·

Now, go and vote my witness 🤓 (only if you want to).

·
·
·

haha, great, didn't know about this bot :D
really cool, you just got a vote :)

·
·
·
·

Thanks! I've written a few spam bots, check them out here: https://contrabourdon.steem.design

·

!witness-vote-check abh12345

·
·

@abh12345, these witnesses you have voted for have retired (or are running a zombie server):

demotruk, pjau


You have 0 witness votes left to use.

You are voting for: actifit, aggroed, arcange, ausbitbank, blockbrothers, blocktrades, busy.witness, c0ff33a, c-squared, curie, danielsaori, demotruk, drakos, emrebeyler, followbtcnews, good-karma, gtg, holger80, kevinwong, lukestokes.mhth, ocd-witness, pharesim, pjau, qurator, roelandp, steemgigs, stoodkev, timcliff, ura-soul, yabapmatt.


Powered by witness untersatz!

·
·
·

What is a zombie server? :)

·
·
·
·

hmm, maybe 'killed' by a hardfork but still not dead?!

·
·
·
·
·

:D

I think they are still running and patched up to date. Out of the top 100 perhaps?

·
·
·
·
·

Or switched to 'seed' mode

Thanks for the tutorial! I'll put it to practice.

·

thanks for the resteem!

·
·

you're welcome! I find it very useful, and if anyone is like me, new to ubuntu and to python (and wanting to learn a bit more), they will appreciate it.

!witness-vote-check geekgirl

·

@geekgirl, these witnesses you have voted for have retired (or are running a zombie server):

demotruk, felixxx


You have 0 witness votes left to use.

You are voting for: adsactly-witness, arcange, ats-witness, blockbrothers, c0ff33a, clayop, crowdwitness, curie, demotruk, drakos, emrebeyler, felixxx, gtg, guiltyparties, holger80, justyy, kevinwong, mahdiyari, neoxian, oflyhigh, pharesim, proxy.token, quochuy, ro-witness, steemgigs, steemhunt, stoodkev, thecryptodrive, themarkymark, therealwolf.


Powered by witness untersatz!