Skip to content

Commit

Permalink
Refactor state field lists to use .drain(). Convert == 0 check to…
Browse files Browse the repository at this point in the history
… `.is_empty()`
  • Loading branch information
EchoAlice committed Apr 26, 2024
1 parent 05acb81 commit 1bcfb14
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions ethereum-consensus/src/electra/epoch_processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,10 @@ pub fn process_pending_balance_deposits<
next_deposit_index += 1;
}

// TODO: Refactor using `.drain()``
state.pending_balance_deposits =
List::try_from(state.pending_balance_deposits.split_off(next_deposit_index)).unwrap();
let deposits_vec: Vec<_> = state.pending_balance_deposits.drain(next_deposit_index..).collect();
state.pending_balance_deposits = List::try_from(deposits_vec).unwrap();

if state.pending_balance_deposits.len() == 0 {
if state.pending_balance_deposits.is_empty() {
state.deposit_balance_to_consume = 0;
} else {
state.deposit_balance_to_consume = available_for_processing - processed_amount;
Expand Down Expand Up @@ -199,9 +198,9 @@ pub fn process_pending_consolidations<
next_pending_consolidation += 1;
}

// TODO: Refactor using `.drain()``
state.pending_consolidations =
List::try_from(state.pending_consolidations.split_off(next_pending_consolidation)).unwrap();
let consolidations_vec: Vec<_> =
state.pending_consolidations.drain(next_pending_consolidation..).collect();
state.pending_consolidations = List::try_from(consolidations_vec).unwrap();

Ok(())
}

0 comments on commit 1bcfb14

Please sign in to comment.