Refactor vote state to remove double negative (#21244)

This commit is contained in:
Justin Starry
2021-11-12 00:26:43 +00:00
committed by GitHub
parent 3c7cb2522c
commit ef29d2d172
2 changed files with 20 additions and 11 deletions

View File

@ -204,7 +204,8 @@ impl Stakes {
let old = self.vote_accounts.remove(pubkey);
// when account is removed (lamports == 0 or data uninitialized), don't read so that
// given `pubkey` can be used for any owner in the future, while not affecting Stakes.
if account.lamports() != 0 && !VoteState::is_uninitialized_no_deser(account.data()) {
if account.lamports() != 0 && VoteState::is_correct_size_and_initialized(account.data())
{
let stake = old.as_ref().map_or_else(
|| self.calculate_stake(pubkey, self.epoch, Some(&self.stake_history)),
|v| v.0,