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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion libraries/chain/include/steem/chain/account_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.


asset balance = asset( 0, STEEM_SYMBOL ); ///< total liquid shares held by this account
asset savings_balance = asset( 0, STEEM_SYMBOL ); ///< total liquid shares held by this account
Expand Down Expand Up @@ -406,7 +407,7 @@ FC_REFLECT( steem::chain::account_object,
(id)(name)(memo_key)(json_metadata)(proxy)(last_account_update)
(created)(mined)
(recovery_account)(last_account_recovery)(reset_account)
(comment_count)(lifetime_vote_count)(post_count)(can_vote)(voting_manabar)
(comment_count)(lifetime_vote_count)(post_count)(can_vote)(voting_manabar)(voting_power)
(balance)
(savings_balance)
(sbd_balance)(sbd_seconds)(sbd_seconds_last_update)(sbd_last_interest_payment)
Expand Down
5 changes: 4 additions & 1 deletion libraries/plugins/apis/condenser_api/condenser_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2082,14 +2082,17 @@ uint16_t api_account_object::_compute_voting_power( const database_api::api_acco
vp_t2 /= vests;

uint64_t vp_t2u = vp_t2.to_uint64();
if( vp_t2u == 0 )
return 0;

if( vp_t2u >= STEEM_100_PERCENT )
{
wlog( "Truncated vp_t2u to STEEM_100_PERCENT for account ${a}", ("a", a.name) );
vp_t2u = STEEM_100_PERCENT;
}
uint16_t vp_t1 = uint16_t( vp_t2u ) - uint16_t( std::min( vp_t2u, vp_dt ) );

return vp_t1;
return vp_t1 ? vp_t1 : a.voting_power;
}

condenser_api::condenser_api()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ struct api_account_object
post_count( a.post_count ),
can_vote( a.can_vote ),
voting_manabar( a.voting_manabar ),
voting_power( a.voting_power ),
balance( a.balance ),
savings_balance( a.savings_balance ),
sbd_balance( a.sbd_balance ),
Expand Down Expand Up @@ -253,6 +254,7 @@ struct api_account_object

bool can_vote = false;
util::manabar voting_manabar;
uint16_t voting_power = 0;

asset balance;
asset savings_balance;
Expand Down Expand Up @@ -566,7 +568,7 @@ FC_REFLECT( steem::plugins::database_api::api_account_object,
(id)(name)(owner)(active)(posting)(memo_key)(json_metadata)(proxy)(last_owner_update)(last_account_update)
(created)(mined)
(recovery_account)(last_account_recovery)(reset_account)
(comment_count)(lifetime_vote_count)(post_count)(can_vote)(voting_manabar)
(comment_count)(lifetime_vote_count)(post_count)(can_vote)(voting_manabar)(voting_power)
(balance)
(savings_balance)
(sbd_balance)(sbd_seconds)(sbd_seconds_last_update)(sbd_last_interest_payment)
Expand Down