Skip to content

Commit

Permalink
perf: inline pooled transactions max (#12805)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Nov 23, 2024
1 parent 13786c7 commit 0d17f14
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/transaction-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ where
&self,
max: usize,
) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
self.pooled_transactions().into_iter().take(max).collect()
self.pool.pooled_transactions_max(max)
}

fn get_pooled_transaction_elements(
Expand Down
8 changes: 8 additions & 0 deletions crates/transaction-pool/src/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,14 @@ where
self.get_pool_data().all().transactions_iter().filter(|tx| tx.propagate).collect()
}

/// Returns only the first `max` transactions in the pool.
pub(crate) fn pooled_transactions_max(
&self,
max: usize,
) -> Vec<Arc<ValidPoolTransaction<T::Transaction>>> {
self.get_pool_data().all().transactions_iter().filter(|tx| tx.propagate).take(max).collect()
}

/// Returns the [`BlobTransaction`] for the given transaction if the sidecar exists.
///
/// Caution: this assumes the given transaction is eip-4844
Expand Down

0 comments on commit 0d17f14

Please sign in to comment.