diff --git a/crates/net/network/src/transactions.rs b/crates/net/network/src/transactions.rs index 6199b46ec..b67675a6f 100644 --- a/crates/net/network/src/transactions.rs +++ b/crates/net/network/src/transactions.rs @@ -47,6 +47,11 @@ const NEW_POOLED_TRANSACTION_HASHES_SOFT_LIMIT: usize = 4096; /// The target size for the message of full transactions. const MAX_FULL_TRANSACTIONS_PACKET_SIZE: usize = 100 * 1024; +/// Recommended soft limit for the number of hashes in a GetPooledTransactions message (8kb) +/// +/// +const GET_POOLED_TRANSACTION_SOFT_LIMIT_NUM_HASHES: usize = 256; + /// The future for inserting a function into the pool pub type PoolImportFuture = Pin> + Send + 'static>>; @@ -332,6 +337,10 @@ where return } + // enforce recommended soft limit, however the peer may enforce an arbitrary limit on + // the response (2MB) + hashes.truncate(GET_POOLED_TRANSACTION_SOFT_LIMIT_NUM_HASHES); + // request the missing transactions let (response, rx) = oneshot::channel(); let req = PeerRequest::GetPooledTransactions {