Skip to content

Commit 8910153

Browse files
committed
Opportunistically skip log in update_claims_view_from_matched_txn
On each block, for each `ChannelMonitor`, we log two status statements in `OnChainTx::update_claims_view_from_matched_txn`. This can add up to quite a bit, and is generally not very interesting when we don't actually do anything if there's no claims to bump. Here we drop both logs if we have no claims to work with, but retain it if we process any claims.
1 parent 9125de2 commit 8910153

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lightning/src/chain/onchaintx.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,8 +861,15 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
861861
B::Target: BroadcasterInterface,
862862
F::Target: FeeEstimator,
863863
{
864-
log_debug!(logger, "Updating claims view at height {} with {} matched transactions in block {}", cur_height, txn_matched.len(), conf_height);
864+
let mut have_logged_intro = false;
865+
let mut maybe_log_intro = || {
866+
if !have_logged_intro {
867+
log_debug!(logger, "Updating claims view at height {} with {} matched transactions in block {}", cur_height, txn_matched.len(), conf_height);
868+
have_logged_intro = true;
869+
}
870+
};
865871
let mut bump_candidates = new_hash_map();
872+
if !txn_matched.is_empty() { maybe_log_intro(); }
866873
for tx in txn_matched {
867874
// Scan all input to verify is one of the outpoint spent is of interest for us
868875
let mut claimed_outputs_material = Vec::new();
@@ -955,6 +962,7 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
955962
self.onchain_events_awaiting_threshold_conf.drain(..).collect::<Vec<_>>();
956963
for entry in onchain_events_awaiting_threshold_conf {
957964
if entry.has_reached_confirmation_threshold(cur_height) {
965+
maybe_log_intro();
958966
match entry.event {
959967
OnchainEvent::Claim { claim_id } => {
960968
// We may remove a whole set of claim outpoints here, as these one may have
@@ -992,7 +1000,11 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
9921000
}
9931001

9941002
// Build, bump and rebroadcast tx accordingly
995-
log_trace!(logger, "Bumping {} candidates", bump_candidates.len());
1003+
if !bump_candidates.is_empty() {
1004+
maybe_log_intro();
1005+
log_trace!(logger, "Bumping {} candidates", bump_candidates.len());
1006+
}
1007+
9961008
for (claim_id, request) in bump_candidates.iter() {
9971009
if let Some((new_timer, new_feerate, bump_claim)) = self.generate_claim(
9981010
cur_height, &request, &FeerateStrategy::ForceBump, &*fee_estimator, &*logger,

0 commit comments

Comments
 (0)