From bdc33ba0a1367a9f794a4078944451ac1ea4be40 Mon Sep 17 00:00:00 2001 From: Brooks Prumo Date: Thu, 2 Dec 2021 14:19:22 -0600 Subject: [PATCH] Remove unnecessary Option (#21569) --- runtime/src/stakes.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/runtime/src/stakes.rs b/runtime/src/stakes.rs index 662c385295..f91417aeac 100644 --- a/runtime/src/stakes.rs +++ b/runtime/src/stakes.rs @@ -68,11 +68,8 @@ impl Stakes { .vote_accounts .iter() .map(|(pubkey, (_ /*stake*/, account))| { - let stake = self.calculate_stake( - pubkey, - next_epoch, - Some(&stake_history_upto_prev_epoch), - ); + let stake = + self.calculate_stake(pubkey, next_epoch, &stake_history_upto_prev_epoch); (*pubkey, (stake, account.clone())) }) .collect(); @@ -159,13 +156,14 @@ impl Stakes { &self, voter_pubkey: &Pubkey, epoch: Epoch, - stake_history: Option<&StakeHistory>, + stake_history: &StakeHistory, ) -> u64 { let matches_voter_pubkey = |(_, stake_delegation): &(&_, &Delegation)| { &stake_delegation.voter_pubkey == voter_pubkey }; - let get_stake = - |(_, stake_delegation): (_, &Delegation)| stake_delegation.stake(epoch, stake_history); + let get_stake = |(_, stake_delegation): (_, &Delegation)| { + stake_delegation.stake(epoch, Some(stake_history)) + }; self.stake_delegations .iter() @@ -205,7 +203,7 @@ impl Stakes { 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)), + || self.calculate_stake(pubkey, self.epoch, &self.stake_history), |v| v.0, );