Skip to content

Commit

Permalink
Only log the propagating transactions when they are not empty (#5424)
Browse files Browse the repository at this point in the history
This can make the log cleaner, especially when you specify `--log
sync=debug`.
  • Loading branch information
liuchengxu authored Aug 27, 2024
1 parent b34d4a0 commit 6ecbde3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
13 changes: 13 additions & 0 deletions prdoc/pr_5424.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: Suppress the log output for transaction propagation when no transactions are present

doc:
- audience: Node Dev
description: |
Previously, the log message `Propagating transactions` would always be printed, even when there were no transactions to propagate. This patch optimizes the logging by returning early when no transactions are present, resulting in cleaner and more relevant log output.

crates:
- name: sc-network-transactions
bump: none
8 changes: 7 additions & 1 deletion substrate/client/network/transactions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,14 @@ where
return
}

debug!(target: LOG_TARGET, "Propagating transactions");
let transactions = self.transaction_pool.transactions();

if transactions.is_empty() {
return
}

debug!(target: LOG_TARGET, "Propagating transactions");

let propagated_to = self.do_propagate_transactions(&transactions);
self.transaction_pool.on_broadcasted(propagated_to);
}
Expand Down

0 comments on commit 6ecbde3

Please sign in to comment.