Skip to content

Commit adeec05

Browse files
committed
Deduplicate payment hash logging
1 parent 3eafe0e commit adeec05

File tree

1 file changed

+27
-31
lines changed

1 file changed

+27
-31
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5243,7 +5243,7 @@ where
52435243
.map_err(|e| {
52445244
let first_hop_key = Some(path.hops.first().unwrap().pubkey);
52455245
let logger = WithContext::from(&self.logger, first_hop_key, None, Some(*payment_hash));
5246-
log_error!(logger, "Failed to build an onion for path for payment hash {payment_hash}");
5246+
log_error!(logger, "Failed to build an onion for path");
52475247
e
52485248
})?;
52495249

@@ -5272,7 +5272,7 @@ where
52725272
);
52735273
log_trace!(
52745274
logger,
5275-
"Attempting to send payment with payment hash {payment_hash} along path with next hop {first_chan_scid}"
5275+
"Attempting to send payment along path with next hop {first_chan_scid}"
52765276
);
52775277

52785278
let per_peer_state = self.per_peer_state.read().unwrap();
@@ -7488,8 +7488,13 @@ where
74887488
} else {
74897489
"alternate"
74907490
};
7491-
log_trace!(logger, "Forwarding HTLC from SCID {} with payment_hash {} and next hop SCID {} over {}",
7492-
prev_outbound_scid_alias, &payment_hash, short_chan_id, channel_description);
7491+
log_trace!(
7492+
logger,
7493+
"Forwarding HTLC from SCID {} with next hop SCID {} over {}",
7494+
prev_outbound_scid_alias,
7495+
short_chan_id,
7496+
channel_description
7497+
);
74937498
if let Err((reason, msg)) = optimal_channel.queue_add_htlc(
74947499
*outgoing_amt_msat,
74957500
*payment_hash,
@@ -7501,12 +7506,7 @@ where
75017506
&self.fee_estimator,
75027507
&&logger,
75037508
) {
7504-
log_trace!(
7505-
logger,
7506-
"Failed to forward HTLC with payment_hash {}: {}",
7507-
&payment_hash,
7508-
msg
7509-
);
7509+
log_trace!(logger, "Failed to forward HTLC: {}", msg);
75107510

75117511
if let Some(chan) = peer_state
75127512
.channel_by_id
@@ -8561,9 +8561,8 @@ where
85618561
}) => {
85628562
log_trace!(
85638563
WithContext::from(&self.logger, None, Some(*channel_id), Some(*payment_hash)),
8564-
"Failing {}HTLC with payment_hash {} backwards from us: {:?}",
8564+
"Failing {}HTLC backwards from us: {:?}",
85658565
if blinded_failure.is_some() { "blinded " } else { "" },
8566-
&payment_hash,
85678566
onion_error
85688567
);
85698568
// In case of trampoline + phantom we prioritize the trampoline failure over the phantom failure.
@@ -12055,11 +12054,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1205512054
None,
1205612055
);
1205712056
} else {
12058-
log_trace!(
12059-
logger,
12060-
"Failing HTLC with hash {} from our monitor",
12061-
&htlc_update.payment_hash
12062-
);
12057+
log_trace!(logger, "Failing HTLC from our monitor");
1206312058
let failure_reason = LocalHTLCFailureReason::OnChainTimeout;
1206412059
let receiver = HTLCHandlingFailureType::Forward {
1206512060
node_id: Some(counterparty_node_id),
@@ -16920,8 +16915,7 @@ where
1692016915
Some(*payment_hash),
1692116916
);
1692216917
log_info!(logger,
16923-
"Failing HTLC with hash {} as it is missing in the ChannelMonitor but was present in the (stale) ChannelManager",
16924-
&payment_hash);
16918+
"Failing HTLC as it is missing in the ChannelMonitor but was present in the (stale) ChannelManager");
1692516919
failed_htlcs.push((
1692616920
channel_htlc_source.clone(),
1692716921
*payment_hash,
@@ -17575,18 +17569,20 @@ where
1757517569
// still have an entry for this HTLC in `forward_htlcs` or
1757617570
// `pending_intercepted_htlcs`, we were apparently not persisted after
1757717571
// the monitor was when forwarding the payment.
17578-
decode_update_add_htlcs.retain(|src_outb_alias, update_add_htlcs| {
17579-
update_add_htlcs.retain(|update_add_htlc| {
17580-
let matches = *src_outb_alias == prev_hop_data.prev_outbound_scid_alias &&
17581-
update_add_htlc.htlc_id == prev_hop_data.htlc_id;
17582-
if matches {
17583-
log_info!(logger, "Removing pending to-decode HTLC with hash {} as it was forwarded to the closed channel",
17584-
&htlc.payment_hash);
17585-
}
17586-
!matches
17587-
});
17588-
!update_add_htlcs.is_empty()
17589-
});
17572+
decode_update_add_htlcs.retain(
17573+
|src_outb_alias, update_add_htlcs| {
17574+
update_add_htlcs.retain(|update_add_htlc| {
17575+
let matches = *src_outb_alias
17576+
== prev_hop_data.prev_outbound_scid_alias
17577+
&& update_add_htlc.htlc_id == prev_hop_data.htlc_id;
17578+
if matches {
17579+
log_info!(logger, "Removing pending to-decode HTLC as it was forwarded to the closed channel");
17580+
}
17581+
!matches
17582+
});
17583+
!update_add_htlcs.is_empty()
17584+
},
17585+
);
1759017586
forward_htlcs.retain(|_, forwards| {
1759117587
forwards.retain(|forward| {
1759217588
if let HTLCForwardInfo::AddHTLC(htlc_info) = forward {

0 commit comments

Comments
 (0)