Skip to content

Commit 1545dcb

Browse files
committed
Simplify extract_batch
1 parent 3569c2d commit 1545dcb

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

crates/batcher/src/types/batch_queue.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,19 @@ pub(crate) fn extract_batch_directly(
201201
return Err(BatcherError::BatchCostTooHigh);
202202
}
203203

204-
// Extract the batch entries (the ones that will pay enough)
205-
let batch_entries = batch_queue.clone().into_sorted_vec();
206-
batch_queue.clear();
204+
// Extract remaining entries in sorted order
205+
// Since pop() gives highest priority first, we collect them directly
206+
let mut batch_for_posting = Vec::new();
207+
while let Some((entry, _)) = batch_queue.pop() {
208+
batch_for_posting.push(entry);
209+
}
207210

208211
// Put back the rejected entries (they stay in the queue for later)
209212
for (entry, priority) in rejected_entries {
210213
batch_queue.push(entry, priority);
211214
}
212215

213-
Ok(batch_entries)
216+
Ok(batch_for_posting)
214217
}
215218

216219
fn calculate_fee_per_proof(batch_len: usize, gas_price: U256, constant_gas_cost: u128) -> U256 {

0 commit comments

Comments
 (0)