Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix zero voting power #3221

Closed

Conversation

economicstudio
Copy link
Contributor

Fix #3217

Currently, a.voting_power of users who haven't voted for more than 5 days but had some financial transaction (e.g., claim reward) is set to 0, which no longer represents the voting power at the a.last_vote_time.

This fix returns the previous a.voting power when this reset happens (unless current_mana is 0, case 2 below).

This fix is safe cause vp_t1 = 0 can occur only in the following two cases:

1) 5 days passed
current voting power (calculated from a.voting_power and a.last_vote_time) will be 100% either way. But this fix is more informative, since it returns the last voting power.

2) vp_t2u = 0
L2085 return 0 (same as before)
Currently, a.voting_power of users who haven't voted for more than 5 days but had some financial transaction (e.g., claim reward) is set to 0, which no longer represents the voting power at the a.last_vote_time.

This fix returns the previous a.voting power when this reset happens (unless current_mana is 0, case 2 below).

This fix is safe cause vp_t1 = 0 can occur only in the following two cases:

1) 5 days passed
current voting power (calculated from a.voting_power and a.last_vote_time) will be 100% either way. But this fix is more informative, since it returns the last voting power.

2) vp_t2u = 0
L2085 return 0 (same as before)
@@ -49,6 +49,7 @@ namespace steem { namespace chain {

bool can_vote = true;
util::manabar voting_manabar;
uint16_t voting_power = 0;
Copy link
Contributor

@mvandeberg mvandeberg Jan 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are adding an unused field to a consensus object just to get an api call to build. The value is always 0, so replace return vp_t1 ? vp_t1 : a.voting_power; with return vp_t1 ? vp_t1 : 0;, which is equivalent to return vp_t1;.

Copy link
Contributor Author

@economicstudio economicstudio Jan 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mvandeberg Thank you for your comment. To be honest, I don't know the very detail of the core blockchain. So I thought adding there and database_api_objects.hpp make it used by the database (so that db keeps the last value) here:

after examining other similar fields. But it isn't?

Then, either please let me know some hints or fix it yourself if this can be done easily without a burden. still hope consistency. As far as I remember, before HF20, it was (not entirely sure though).

By the way, I'm fairly familiar with API (especially Python, I wrote a bot with it and it's working well) Now I'm also interested in the core, is there any good doc? Any dev/test doc (e.g., how to test this code? Since I don't know, I only tested steemd is loading) would be great. Thanks.

@sgerbino
Copy link
Contributor

sgerbino commented May 1, 2019

Continuation of #3220.

@mvandeberg
Copy link
Contributor

This is a stale PR that doesn't change any behavior of our APIs. I am closing it.

@mvandeberg mvandeberg closed this May 17, 2019
@economicstudio
Copy link
Contributor Author

@mvandeberg No problem and thanks for having considered it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants