Skip to content

Commit

Permalink
fix find entry by epoch logic in set_mev_commission
Browse files Browse the repository at this point in the history
  • Loading branch information
0xprames committed Jan 11, 2024
1 parent a7b1299 commit efe26cb
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions programs/validator-history/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit efe26cb

Please sign in to comment.