mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 09:08:05 -05:00
Support soft limit in NewPooledTransactions (#1577)
This commit is contained in:
@@ -36,6 +36,9 @@ use tracing::trace;
|
||||
/// Cache limit of transactions to keep track of for a single peer.
|
||||
const PEER_TRANSACTION_CACHE_LIMIT: usize = 1024 * 10;
|
||||
|
||||
/// Soft limit for NewPooledTransactions
|
||||
const NEW_POOLED_TRANSACTION_HASHES_SOFT_LIMT: usize = 4096;
|
||||
|
||||
/// The future for inserting a function into the pool
|
||||
pub type PoolImportFuture = Pin<Box<dyn Future<Output = PoolResult<TxHash>> + Send + 'static>>;
|
||||
|
||||
@@ -352,7 +355,23 @@ where
|
||||
// Send a `NewPooledTransactionHashes` to the peer with _all_ transactions in the
|
||||
// pool
|
||||
if !self.network.is_syncing() {
|
||||
todo!("get access to full tx");
|
||||
let mut hashes = PooledTransactionsHashesBuilder::new(version);
|
||||
let to_propogate = self.pool.pooled_transactions().into_iter().map(|tx| {
|
||||
let tx = Arc::new(tx.transaction.to_recovered_transaction().into_signed());
|
||||
PropagateTransaction::new(tx)
|
||||
});
|
||||
|
||||
for tx in to_propogate.take(NEW_POOLED_TRANSACTION_HASHES_SOFT_LIMT) {
|
||||
let peer = self.peers.get_mut(&peer_id).unwrap();
|
||||
|
||||
if peer.transactions.insert(tx.hash()) {
|
||||
hashes.push(&tx);
|
||||
}
|
||||
}
|
||||
|
||||
let hashes = hashes.build();
|
||||
|
||||
self.network.send_transactions_hashes(peer_id, hashes);
|
||||
// let msg = NewPooledTransactionHashes66(self.pool.pooled_transactions());
|
||||
// self.network.send_message(NetworkHandleMessage::SendPooledTransactionHashes {
|
||||
// peer_id,
|
||||
|
||||
Reference in New Issue
Block a user