From 55e3474b86f85d01d10e75aeaddb31f68e43700d Mon Sep 17 00:00:00 2001 From: Jon C Date: Wed, 20 Sep 2023 16:55:20 +0200 Subject: [PATCH] Move error check --- stake-pool/program/src/processor.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stake-pool/program/src/processor.rs b/stake-pool/program/src/processor.rs index ee4b612d5af..762f1bea6ae 100644 --- a/stake-pool/program/src/processor.rs +++ b/stake-pool/program/src/processor.rs @@ -1398,14 +1398,14 @@ impl Processor { // if needed, withdraw rent-exempt reserve for ephemeral account if let Some(reserve_stake_info) = maybe_reserve_stake_info { - let stake_history_info = - maybe_stake_history_info.ok_or(StakePoolError::MissingRequiredSysvar)?; let required_lamports_for_rent_exemption = stake_rent.saturating_sub(ephemeral_stake_account_info.lamports()); - if required_lamports_for_rent_exemption >= reserve_stake_info.lamports() { - return Err(StakePoolError::ReserveDepleted.into()); - } if required_lamports_for_rent_exemption > 0 { + if required_lamports_for_rent_exemption >= reserve_stake_info.lamports() { + return Err(StakePoolError::ReserveDepleted.into()); + } + let stake_history_info = maybe_stake_history_info + .ok_or(StakePoolError::MissingRequiredSysvar)?; Self::stake_withdraw( stake_pool_info.key, reserve_stake_info.clone(),