From 2ce72c51e10640e28def1dc8a51a01ac9021fe23 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Thu, 23 Mar 2023 19:13:00 -0400 Subject: [PATCH] fix: do not send pooled transactions if pool is empty (#1949) --- crates/net/network/src/transactions.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/net/network/src/transactions.rs b/crates/net/network/src/transactions.rs index a49bfd674a..4e06c5af6b 100644 --- a/crates/net/network/src/transactions.rs +++ b/crates/net/network/src/transactions.rs @@ -368,11 +368,14 @@ where let mut msg_builder = PooledTransactionsHashesBuilder::new(version); - for pooled_tx in self - .pool - .pooled_transactions() - .into_iter() - .take(NEW_POOLED_TRANSACTION_HASHES_SOFT_LIMIT) + let pooled_txs = self.pool.pooled_transactions(); + 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) { peer.transactions.insert(*pooled_tx.hash()); msg_builder.push_pooled(pooled_tx);