-
Notifications
You must be signed in to change notification settings - Fork 786
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
Fix zero voting power #3221
Conversation
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; |
There was a problem hiding this comment.
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;
.
There was a problem hiding this comment.
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:
steem/libraries/plugins/apis/condenser_api/include/steem/plugins/condenser_api/condenser_api.hpp
Line 151 in 69c94e4
voting_power = _compute_voting_power(a); |
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.
Continuation of #3220. |
This is a stale PR that doesn't change any behavior of our APIs. I am closing it. |
@mvandeberg No problem and thanks for having considered it. |
Fix #3217