From 73ddfccaab64b75e18da114f0de96bbb08b10177 Mon Sep 17 00:00:00 2001 From: abitmore Date: Sat, 9 May 2020 16:12:24 -0400 Subject: [PATCH] Improve performance for account_update --- libraries/chain/account_evaluator.cpp | 14 +++++++------- .../include/graphene/chain/account_object.hpp | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index 4480d48530..413c09e618 100644 --- a/libraries/chain/account_evaluator.cpp +++ b/libraries/chain/account_evaluator.cpp @@ -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 diff --git a/libraries/chain/include/graphene/chain/account_object.hpp b/libraries/chain/include/graphene/chain/account_object.hpp index 1f610eb55a..ef5b8197b0 100644 --- a/libraries/chain/include/graphene/chain/account_object.hpp +++ b/libraries/chain/include/graphene/chain/account_object.hpp @@ -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