Updated vote tallying, skipping non-existing accounts

This commit is contained in:
Michael Neynens 2018-08-07 18:04:17 -07:00
parent d5d7900cb4
commit 1c1026516a
2 changed files with 9 additions and 4 deletions

View file

@ -68,6 +68,7 @@ void verify_account_votes( const database& db, const account_options& options )
"Voted for more witnesses than currently allowed (${c})", ("c", chain_params.maximum_witness_count) );
FC_ASSERT( options.num_committee <= chain_params.maximum_committee_count,
"Voted for more committee members than currently allowed (${c})", ("c", chain_params.maximum_committee_count) );
FC_ASSERT( db.find_object(options.voting_account), "Invalid proxy account specified." );
uint32_t max_vote_id = gpo.next_available_vote_id;
bool has_worker_votes = false;
@ -108,7 +109,6 @@ void_result account_create_evaluator::do_evaluate( const account_create_operatio
FC_ASSERT( !op.extensions.value.buyback_options.valid() );
}
FC_ASSERT( d.find_object(op.options.voting_account), "Invalid proxy account specified." );
FC_ASSERT( fee_paying_account->is_lifetime_member(), "Only Lifetime members may register an account." );
FC_ASSERT( op.referrer(d).is_member(d.head_block_time()), "The referrer must be either a lifetime or annual subscriber." );

View file

@ -1244,10 +1244,15 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g
// There may be a difference between the account whose stake is voting and the one specifying opinions.
// Usually they're the same, but if the stake account has specified a voting_account, that account is the one
// specifying the opinions.
const account_object& opinion_account =
const account_object* opinion_account_ptr =
(stake_account.options.voting_account ==
GRAPHENE_PROXY_TO_SELF_ACCOUNT)? stake_account
: d.get(stake_account.options.voting_account);
GRAPHENE_PROXY_TO_SELF_ACCOUNT)? &stake_account
: d.find(stake_account.options.voting_account);
if( !opinion_account_ptr ) // skip non-exist account
return;
const account_object& opinion_account = *opinion_account_ptr;
const auto& stats = stake_account.statistics(d);
uint64_t voting_stake = stats.total_core_in_orders.value