From efe26cb3d922d8c441cf971dfe591e07feab1664 Mon Sep 17 00:00:00 2001 From: 0xprames <0xprames@proton.me> Date: Sun, 7 Jan 2024 23:18:41 -0500 Subject: [PATCH] fix find entry by epoch logic in set_mev_commission --- programs/validator-history/src/state.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/programs/validator-history/src/state.rs b/programs/validator-history/src/state.rs index 5b699ad2..e47ad555 100644 --- a/programs/validator-history/src/state.rs +++ b/programs/validator-history/src/state.rs @@ -275,12 +275,14 @@ impl ValidatorHistory { mev_earned: u64, ) -> Result<()> { // check if entry exists for the epoch - if let Some(entry) = self.history.last_mut() { - if entry.epoch == epoch { + self.history + .arr + .iter_mut() + .filter(|entry| entry.epoch == epoch) + .for_each(|entry| { + entry.mev_earned = mev_earned; entry.mev_commission = commission; - return Ok(()); - } - } + }); let entry = ValidatorHistoryEntry { epoch, mev_commission: commission,