Shown Voting Power is not the current value

in #utopian-io8 years ago (edited)

Expected behavior

The utopian-moderator extension should show the current utopian-io voting power

Actual behavior

screenshot.png

The extension shows the utopian-io voting power at the time of the last utopian vote. The voting_power field in the steem account information only stores the VP at the time of the last vote, not the current value:

>>> from steem.account import Account
>>> a = Account("utopian-io")
>>> a['voting_power']
6680

In order to get the current VP, one has to calculate the voting power regeneration since the last vote. Here's the python-equivalent to get the current voting power:


def get_voting_power(account):
    """get current voting power. The 'last_vote_time' value in the account
    data only contains the VP at the time of the last vote.

    """
    last_vote_time = parse(account['last_vote_time'])
    diff = (dt.datetime.utcnow() - last_vote_time).total_seconds()
    regenerated_vp = diff * 10000 / 86400 / 5
    total_vp = (account['voting_power'] + regenerated_vp) / 100.0
    if total_vp > 100:
        total_vp = 100.0
    return total_vp

How to reproduce

Compare the value in the extension with those on steemd/steemworld/...

Here is the corresponding part in the code:
https://github.com/DoctorLai/utopian-moderator/blob/2c9d77f73b344191cf850d28a419413961cc8fd1/js/utopian.js#L391

@justyy, steemtools seems to be affected as well:
https://github.com/DoctorLai/SteemTools/blob/24283592c488f23b0df4218982ecb801343d2496/js/steemtools.js#L36



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

Thanks! good catch.. You can submit the PR to fix or wait till my next version. :)

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

Hey @stmdev 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!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

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