STEEM-SockoBot - fix fetching payouts bug

in #utopian-io8 years ago (edited)

image.png

I would like to help @jestemkioskiem in fixing the 'nasty bug' he mentioned here https://utopian.io/utopian-io/@jestemkioskiem/fix-a-nasty-bug-inside-of-a-steem-discord-bot-20-steem-bounty

image.png

The bug

I did some tests and it is true that for some users, calculating their pending payouts value was taking very long or never at all.
It takes ages especially for users who:

  • has old account
  • rarely posts anything
  • posts huge articles with many comments inside

I have realized that steem-python library is terribly inefficient. For retrieving someone's posts it traverses through blockchain and downloads huge amount of data from nodes. It is client job to filter that. This is why retrieving old posts takes so long.
Furthermore, it seems like steem-python downloads not only posts metadata but it's body, voters, their vests, blog comments etc. also! That's very huge amount of data.

I decided to switch to another API

Exploring the Internet I realized there aren't many good API nodes. There is one Python API (steem-python I disliked), one Javascript, one PHP... and that's all. Even busy.org and utopian.io uses api.steemit.com! If both these big portals use that, I decided it is the best to use it too.

The only job is to post good query:
image.png
I hope retrieving 50 posts is enough for 7 day timeframe. But it's no problem to extend that to 100 or more.

@jestemkioskiem, I did some code refactoring also. I hope the code inside fetch_payouts() is a little bit cleaner now :>

Conclusion

This way calculating pending payouts in USD is done immediately :) It's shame we couldn't fix that using steem-python API.
STEEM developers! For God's sake do smth with that. Now I see why STEEM developing is so slow...

My contribution to Jestemkioskiem/steem-sockobot:
https://github.com/Jestemkioskiem/steem-sockobot/pull/1



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Hey @mys I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Coin Marketplace

STEEM 0.08
TRX 0.30
JST 0.037
BTC 102830.58
ETH 3444.49
USDT 1.00
SBD 0.55