create account

Shown Voting Power is not the current value by stmdev

View this thread on: hive.blogpeakd.comecency.com
· @stmdev · (edited)
$11.00
Shown Voting Power is not the current value
#### Expected behavior
The utopian-moderator extension should show the current utopian-io voting power


#### Actual behavior
![screenshot.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1518783521/ze9xsp0vrhogxowgvzkz.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:

```python
>>> 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

<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@stmdev/vp-calculation-is-wrong">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍  , , , , ,
properties (23)
authorstmdev
permlinkvp-calculation-is-wrong
categoryutopian-io
json_metadata"{"community":"utopian","app":"utopian/1.0.0","format":"markdown","repository":{"id":119434075,"name":"utopian-moderator","full_name":"DoctorLai/utopian-moderator","html_url":"https://github.com/DoctorLai/utopian-moderator","fork":false,"owner":{"login":"DoctorLai"}},"pullRequests":[],"platform":"github","type":"bug-hunting","tags":["utopian-io","moderator","extension","bug","votingpower"],"users":["justyy","stmdev"],"links":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1518783521/ze9xsp0vrhogxowgvzkz.png"],"image":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1518783521/ze9xsp0vrhogxowgvzkz.png"],"moderator":{"account":"justyy","time":"2018-02-17T21:42:29.595Z","reviewed":true,"pending":false,"flagged":false},"questions":[],"score":0,"issue":{"url":"https://github.com/DoctorLai/utopian-moderator/issues/2","number":2,"id":298038935,"title":"Shown Voting Power is not the current value"}}"
created2018-02-16 12:23:33
last_update2018-02-17 21:42:33
depth0
children2
last_payout2018-02-23 12:23:33
cashout_time1969-12-31 23:59:59
total_payout_value7.624 HBD
curator_payout_value3.372 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,782
author_reputation10,427,398,400,460
root_title"Shown Voting Power is not the current value"
beneficiaries
0.
accountutopian.pay
weight2,500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id37,992,678
net_rshares2,240,251,694,026
author_curate_reward""
vote details (6)
@justyy ·
$0.16
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](https://discord.gg/uTyJkNm).
**[[utopian-moderator]](https://utopian.io/moderators)**
👍  
properties (23)
authorjustyy
permlinkre-stmdev-vp-calculation-is-wrong-20180217t214315558z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-02-17 21:43:15
last_update2018-02-17 21:43:15
depth1
children0
last_payout2018-02-24 21:43:15
cashout_time1969-12-31 23:59:59
total_payout_value0.122 HBD
curator_payout_value0.037 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length257
author_reputation280,616,224,641,976
root_title"Shown Voting Power is not the current value"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id38,357,022
net_rshares28,170,983,148
author_curate_reward""
vote details (1)
@utopian-io ·
### 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. <a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER!
- <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness With SteemConnect</a>
- <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness with SteemConnect</a>
- Or vote/proxy on <a href="https://steemit.com/~witnesses">Steemit Witnesses</a>

[![mooncryption-utopian-witness-gif](https://steemitimages.com/DQmYPUuQRptAqNBCQRwQjKWAqWU3zJkL3RXVUtEKVury8up/mooncryption-s-utopian-io-witness-gif.gif)](https://steemit.com/~witnesses)

**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**
properties (22)
authorutopian-io
permlinkre-stmdev-vp-calculation-is-wrong-20180218t150106545z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-02-18 15:01:06
last_update2018-02-18 15:01:06
depth1
children0
last_payout2018-02-25 15:01:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,504
author_reputation152,955,367,999,756
root_title"Shown Voting Power is not the current value"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id38,536,384
net_rshares0