Skip to content

Commit 3fd4b39

Browse files
authored
Merge pull request #2895 from TheBlueMatt/2024-02-logging-tweaks
Minor Logging tweaks
2 parents 3fd85c8 + 8910153 commit 3fd4b39

File tree

4 files changed

+32
-10
lines changed

4 files changed

+32
-10
lines changed

lightning/src/chain/onchaintx.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,10 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
726726
B::Target: BroadcasterInterface,
727727
F::Target: FeeEstimator,
728728
{
729-
log_debug!(logger, "Updating claims view at height {} with {} claim requests", cur_height, requests.len());
729+
if !requests.is_empty() {
730+
log_debug!(logger, "Updating claims view at height {} with {} claim requests", cur_height, requests.len());
731+
}
732+
730733
let mut preprocessed_requests = Vec::with_capacity(requests.len());
731734
let mut aggregated_request = None;
732735

@@ -772,6 +775,12 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
772775

773776
// Claim everything up to and including `cur_height`
774777
let remaining_locked_packages = self.locktimed_packages.split_off(&(cur_height + 1));
778+
if !self.locktimed_packages.is_empty() {
779+
log_debug!(logger,
780+
"Updating claims view at height {} with {} locked packages available for claim",
781+
cur_height,
782+
self.locktimed_packages.len());
783+
}
775784
for (pop_height, mut entry) in self.locktimed_packages.iter_mut() {
776785
log_trace!(logger, "Restoring delayed claim of package(s) at their timelock at {}.", pop_height);
777786
preprocessed_requests.append(&mut entry);
@@ -852,8 +861,15 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
852861
B::Target: BroadcasterInterface,
853862
F::Target: FeeEstimator,
854863
{
855-
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+
};
856871
let mut bump_candidates = new_hash_map();
872+
if !txn_matched.is_empty() { maybe_log_intro(); }
857873
for tx in txn_matched {
858874
// Scan all input to verify is one of the outpoint spent is of interest for us
859875
let mut claimed_outputs_material = Vec::new();
@@ -946,6 +962,7 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
946962
self.onchain_events_awaiting_threshold_conf.drain(..).collect::<Vec<_>>();
947963
for entry in onchain_events_awaiting_threshold_conf {
948964
if entry.has_reached_confirmation_threshold(cur_height) {
965+
maybe_log_intro();
949966
match entry.event {
950967
OnchainEvent::Claim { claim_id } => {
951968
// We may remove a whole set of claim outpoints here, as these one may have
@@ -983,7 +1000,11 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
9831000
}
9841001

9851002
// Build, bump and rebroadcast tx accordingly
986-
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+
9871008
for (claim_id, request) in bump_candidates.iter() {
9881009
if let Some((new_timer, new_feerate, bump_claim)) = self.generate_claim(
9891010
cur_height, &request, &FeerateStrategy::ForceBump, &*fee_estimator, &*logger,

lightning/src/ln/channelmanager.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4833,10 +4833,6 @@ where
48334833

48344834
// If the feerate has decreased by less than half, don't bother
48354835
if new_feerate <= chan.context.get_feerate_sat_per_1000_weight() && new_feerate * 2 > chan.context.get_feerate_sat_per_1000_weight() {
4836-
if new_feerate != chan.context.get_feerate_sat_per_1000_weight() {
4837-
log_trace!(logger, "Channel {} does not qualify for a feerate change from {} to {}.",
4838-
chan_id, chan.context.get_feerate_sat_per_1000_weight(), new_feerate);
4839-
}
48404836
return NotifyOption::SkipPersistNoEvents;
48414837
}
48424838
if !chan.context.is_live() {

lightning/src/ln/peer_handler.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use crate::onion_message::offers::{OffersMessage, OffersMessageHandler};
3333
use crate::onion_message::packet::OnionMessageContents;
3434
use crate::routing::gossip::{NodeId, NodeAlias};
3535
use crate::util::atomic_counter::AtomicCounter;
36-
use crate::util::logger::{Logger, WithContext};
36+
use crate::util::logger::{Level, Logger, WithContext};
3737
use crate::util::string::PrintableString;
3838

3939
use crate::prelude::*;
@@ -1329,7 +1329,9 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
13291329
return Err(PeerHandleError { });
13301330
},
13311331
msgs::ErrorAction::IgnoreAndLog(level) => {
1332-
log_given_level!(logger, level, "Error handling message{}; ignoring: {}", OptionalFromDebugger(&peer_node_id), e.err);
1332+
log_given_level!(logger, level, "Error handling {}message{}; ignoring: {}",
1333+
if level == Level::Gossip { "gossip " } else { "" },
1334+
OptionalFromDebugger(&peer_node_id), e.err);
13331335
continue
13341336
},
13351337
msgs::ErrorAction::IgnoreDuplicateGossip => continue, // Don't even bother logging these

lightning/src/routing/gossip.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1925,7 +1925,10 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
19251925
None => {
19261926
core::mem::drop(channels);
19271927
self.pending_checks.check_hold_pending_channel_update(msg, full_msg)?;
1928-
return Err(LightningError{err: "Couldn't find channel for update".to_owned(), action: ErrorAction::IgnoreError});
1928+
return Err(LightningError {
1929+
err: "Couldn't find channel for update".to_owned(),
1930+
action: ErrorAction::IgnoreAndLog(Level::Gossip),
1931+
});
19291932
},
19301933
Some(channel) => {
19311934
if msg.htlc_maximum_msat > MAX_VALUE_MSAT {

0 commit comments

Comments
 (0)