Skip to content

Commit

Permalink
Merge pull request #2173 from bitshares/pr-optimize-account-update
Browse files Browse the repository at this point in the history
Improve performance for account_update
  • Loading branch information
abitmore authored May 10, 2020
2 parents fde2aa4 + 73ddfcc commit 784af1b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions libraries/chain/account_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,15 @@ void_result account_update_evaluator::do_apply( const account_update_operation&
// update account statistics
if( o.new_options.valid() )
{
d.modify( acnt->statistics( d ), [&]( account_statistics_object& aso )
if ( o.new_options->voting_account != acnt->options.voting_account
|| o.new_options->votes != acnt->options.votes )
{
if(o.new_options->is_voting() != acnt->options.is_voting())
aso.is_voting = !aso.is_voting;

if((o.new_options->votes != acnt->options.votes ||
o.new_options->voting_account != acnt->options.voting_account))
d.modify( acnt->statistics( d ), [&d,&o]( account_statistics_object& aso )
{
aso.is_voting = o.new_options->is_voting();
aso.last_vote_time = d.head_block_time();
} );
} );
}
}

// update account object
Expand Down
4 changes: 2 additions & 2 deletions libraries/chain/include/graphene/chain/account_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ namespace graphene { namespace chain {

bool has_cashback_vb = false; ///< redundantly store this for better maintenance performance

bool is_voting = false; ///< redundately store whether this account is voting for better maintenance performance
bool is_voting = false; ///< redundately store "if this account is voting" for better maintenance performance

time_point_sec last_vote_time; // add last time voted
time_point_sec last_vote_time; ///< last time voted

/// Whether this account owns some CORE asset and is voting
inline bool has_some_core_voting() const
Expand Down

0 comments on commit 784af1b

Please sign in to comment.