Skip to content

Commit 7f96446

Browse files
authored
Merge pull request lightningdevkit#2771 from tnull/2023-12-log-details-for-ignored-first-hop
Log additional details when ignoring first hops
2 parents 4d66cce + 52ecce9 commit 7f96446

File tree

1 file changed

+43
-6
lines changed

1 file changed

+43
-6
lines changed

lightning/src/routing/router.rs

+43-6
Original file line numberDiff line numberDiff line change
@@ -1795,12 +1795,12 @@ where L::Target: Logger {
17951795
let payment_failed_on_this_channel = scid_opt.map_or(false,
17961796
|scid| payment_params.previously_failed_channels.contains(&scid));
17971797

1798-
let should_log_candidate = match $candidate {
1799-
CandidateRouteHop::FirstHop { .. } => true,
1800-
CandidateRouteHop::PrivateHop { .. } => true,
1801-
CandidateRouteHop::Blinded { .. } => true,
1802-
CandidateRouteHop::OneHopBlinded { .. } => true,
1803-
_ => false,
1798+
let (should_log_candidate, first_hop_details) = match $candidate {
1799+
CandidateRouteHop::FirstHop { details } => (true, Some(details)),
1800+
CandidateRouteHop::PrivateHop { .. } => (true, None),
1801+
CandidateRouteHop::Blinded { .. } => (true, None),
1802+
CandidateRouteHop::OneHopBlinded { .. } => (true, None),
1803+
_ => (false, None),
18041804
};
18051805

18061806
// If HTLC minimum is larger than the amount we're going to transfer, we shouldn't
@@ -1810,6 +1810,13 @@ where L::Target: Logger {
18101810
if !contributes_sufficient_value {
18111811
if should_log_candidate {
18121812
log_trace!(logger, "Ignoring {} due to insufficient value contribution.", LoggedCandidateHop(&$candidate));
1813+
1814+
if let Some(details) = first_hop_details {
1815+
log_trace!(logger,
1816+
"First hop candidate next_outbound_htlc_limit_msat: {}",
1817+
details.next_outbound_htlc_limit_msat,
1818+
);
1819+
}
18131820
}
18141821
num_ignored_value_contribution += 1;
18151822
} else if exceeds_max_path_length {
@@ -1820,6 +1827,14 @@ where L::Target: Logger {
18201827
} else if exceeds_cltv_delta_limit {
18211828
if should_log_candidate {
18221829
log_trace!(logger, "Ignoring {} due to exceeding CLTV delta limit.", LoggedCandidateHop(&$candidate));
1830+
1831+
if let Some(_) = first_hop_details {
1832+
log_trace!(logger,
1833+
"First hop candidate cltv_expiry_delta: {}. Limit: {}",
1834+
hop_total_cltv_delta,
1835+
max_total_cltv_expiry_delta,
1836+
);
1837+
}
18231838
}
18241839
num_ignored_cltv_delta_limit += 1;
18251840
} else if payment_failed_on_this_channel {
@@ -1832,6 +1847,13 @@ where L::Target: Logger {
18321847
log_trace!(logger,
18331848
"Ignoring {} to avoid overpaying to meet htlc_minimum_msat limit.",
18341849
LoggedCandidateHop(&$candidate));
1850+
1851+
if let Some(details) = first_hop_details {
1852+
log_trace!(logger,
1853+
"First hop candidate next_outbound_htlc_minimum_msat: {}",
1854+
details.next_outbound_htlc_minimum_msat,
1855+
);
1856+
}
18351857
}
18361858
num_ignored_avoid_overpayment += 1;
18371859
hit_minimum_limit = true;
@@ -1893,6 +1915,14 @@ where L::Target: Logger {
18931915
if total_fee_msat > max_total_routing_fee_msat {
18941916
if should_log_candidate {
18951917
log_trace!(logger, "Ignoring {} due to exceeding max total routing fee limit.", LoggedCandidateHop(&$candidate));
1918+
1919+
if let Some(_) = first_hop_details {
1920+
log_trace!(logger,
1921+
"First hop candidate routing fee: {}. Limit: {}",
1922+
total_fee_msat,
1923+
max_total_routing_fee_msat,
1924+
);
1925+
}
18961926
}
18971927
num_ignored_total_fee_limit += 1;
18981928
} else {
@@ -1988,6 +2018,13 @@ where L::Target: Logger {
19882018
log_trace!(logger,
19892019
"Ignoring {} due to its htlc_minimum_msat limit.",
19902020
LoggedCandidateHop(&$candidate));
2021+
2022+
if let Some(details) = first_hop_details {
2023+
log_trace!(logger,
2024+
"First hop candidate next_outbound_htlc_minimum_msat: {}",
2025+
details.next_outbound_htlc_minimum_msat,
2026+
);
2027+
}
19912028
}
19922029
num_ignored_htlc_minimum_msat_limit += 1;
19932030
}

0 commit comments

Comments
 (0)