mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-30 01:28:21 -05:00
feat: add pooled_transaction_max (#1971)
This commit is contained in:
@@ -368,15 +368,14 @@ where
|
||||
|
||||
let mut msg_builder = PooledTransactionsHashesBuilder::new(version);
|
||||
|
||||
let pooled_txs = self.pool.pooled_transactions();
|
||||
let pooled_txs =
|
||||
self.pool.pooled_transactions_max(NEW_POOLED_TRANSACTION_HASHES_SOFT_LIMIT);
|
||||
if pooled_txs.is_empty() {
|
||||
// do not send a message if there are no transactions in the pool
|
||||
return
|
||||
}
|
||||
|
||||
for pooled_tx in
|
||||
pooled_txs.into_iter().take(NEW_POOLED_TRANSACTION_HASHES_SOFT_LIMIT)
|
||||
{
|
||||
for pooled_tx in pooled_txs.into_iter() {
|
||||
peer.transactions.insert(*pooled_tx.hash());
|
||||
msg_builder.push_pooled(pooled_tx);
|
||||
}
|
||||
|
||||
@@ -283,6 +283,17 @@ where
|
||||
self.pool.pooled_transactions()
|
||||
}
|
||||
|
||||
fn pooled_transaction_hashes_max(&self, max: usize) -> Vec<TxHash> {
|
||||
self.pooled_transaction_hashes().into_iter().take(max).collect()
|
||||
}
|
||||
|
||||
fn pooled_transactions_max(
|
||||
&self,
|
||||
max: usize,
|
||||
) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>> {
|
||||
self.pooled_transactions().into_iter().take(max).collect()
|
||||
}
|
||||
|
||||
fn best_transactions(
|
||||
&self,
|
||||
) -> Box<dyn BestTransactions<Item = Arc<ValidPoolTransaction<Self::Transaction>>>> {
|
||||
|
||||
@@ -79,6 +79,11 @@ pub trait TransactionPool: Send + Sync + Clone {
|
||||
/// Consumer: P2P
|
||||
fn pooled_transaction_hashes(&self) -> Vec<TxHash>;
|
||||
|
||||
/// Returns only the first `max` hashes of transactions in the pool.
|
||||
///
|
||||
/// Consumer: P2P
|
||||
fn pooled_transaction_hashes_max(&self, max: usize) -> Vec<TxHash>;
|
||||
|
||||
/// Returns the _full_ transaction objects all transactions in the pool.
|
||||
///
|
||||
/// Note: This returns a `Vec` but should guarantee that all transactions are unique.
|
||||
@@ -86,6 +91,14 @@ pub trait TransactionPool: Send + Sync + Clone {
|
||||
/// Consumer: P2P
|
||||
fn pooled_transactions(&self) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>>;
|
||||
|
||||
/// Returns only the first `max` transactions in the pool.
|
||||
///
|
||||
/// Consumer: P2P
|
||||
fn pooled_transactions_max(
|
||||
&self,
|
||||
max: usize,
|
||||
) -> Vec<Arc<ValidPoolTransaction<Self::Transaction>>>;
|
||||
|
||||
/// Returns an iterator that yields transactions that are ready for block production.
|
||||
///
|
||||
/// Consumer: Block production
|
||||
|
||||
Reference in New Issue
Block a user