From 1b60ada997c0b676fbb6796e7e14190f3319650c Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Fri, 26 Apr 2024 13:30:14 -0700 Subject: [PATCH] lint --- consensus/types/src/beacon_state.rs | 16 +++++++--------- consensus/types/src/validator.rs | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/consensus/types/src/beacon_state.rs b/consensus/types/src/beacon_state.rs index 8f2f8761a9c..577f282a556 100644 --- a/consensus/types/src/beacon_state.rs +++ b/consensus/types/src/beacon_state.rs @@ -2113,17 +2113,15 @@ impl BeaconState { } pub fn get_pending_balance_to_withdraw(&self, validator_index: usize) -> Result { - Ok(self + let mut pending_balance = 0; + for withdrawal in self .pending_partial_withdrawals()? .iter() - .filter_map(|withdrawal| { - if withdrawal.index as usize == validator_index { - Some(withdrawal.amount) - } else { - None - } - }) - .sum()) + .filter(|withdrawal| withdrawal.index as usize == validator_index) + { + pending_balance.safe_add_assign(withdrawal.amount)?; + } + Ok(pending_balance) } // ******* Electra mutators ******* diff --git a/consensus/types/src/validator.rs b/consensus/types/src/validator.rs index 1321b570074..a84bb401268 100644 --- a/consensus/types/src/validator.rs +++ b/consensus/types/src/validator.rs @@ -153,7 +153,7 @@ impl Validator { } /// Returns `true` if the validator if fully withdrawable. - /// + /// /// Modified in electra. pub fn is_fully_withdrawable_validator( &self,