diff --git a/substrate/frame/staking/src/lib.rs b/substrate/frame/staking/src/lib.rs index 4cf0596ddc..eb0817c2e5 100644 --- a/substrate/frame/staking/src/lib.rs +++ b/substrate/frame/staking/src/lib.rs @@ -2346,10 +2346,10 @@ impl Pallet { era: EraIndex, ) -> DispatchResultWithPostInfo { // Validate input data - let current_era = CurrentEra::::get().ok_or( + let current_era = CurrentEra::::get().ok_or_else(|| { Error::::InvalidEraToReward - .with_weight(T::WeightInfo::payout_stakers_alive_staked(0)), - )?; + .with_weight(T::WeightInfo::payout_stakers_alive_staked(0)) + })?; let history_depth = Self::history_depth(); ensure!( era <= current_era && era >= current_era.saturating_sub(history_depth), @@ -2364,10 +2364,11 @@ impl Pallet { .with_weight(T::WeightInfo::payout_stakers_alive_staked(0)) })?; - let controller = Self::bonded(&validator_stash).ok_or( - Error::::NotStash.with_weight(T::WeightInfo::payout_stakers_alive_staked(0)), - )?; - let mut ledger = >::get(&controller).ok_or_else(|| Error::::NotController)?; + let controller = Self::bonded(&validator_stash).ok_or_else(|| { + Error::::NotStash + .with_weight(T::WeightInfo::payout_stakers_alive_staked(0)) + })?; + let mut ledger = >::get(&controller).ok_or(Error::::NotController)?; ledger .claimed_rewards @@ -3127,7 +3128,7 @@ impl frame_election_provider_support::ElectionDataProvider = target_stake .and_then(|w| >::try_from(w).ok()) - .unwrap_or(MinNominatorBond::::get() * 100u32.into()); + .unwrap_or_else(|| MinNominatorBond::::get() * 100u32.into()); >::insert(v.clone(), v.clone()); >::insert( v.clone(),