Skip to content

Commit 1618be5

Browse files
committed
Consider channels with one direction useless for routing
This is actually only useful when we just restarted and received an outdated channel update, which we keep for STALE_CHANNEL_UPDATE_AGE_LIMIT_SECS to give it a chance to send a channel update. During that time, we still should not be used it for routing.
1 parent 427ced6 commit 1618be5

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

lightning/src/routing/router.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,19 +1274,23 @@ where L::Target: Logger {
12741274
for chan_id in $node.channels.iter() {
12751275
let chan = network_channels.get(chan_id).unwrap();
12761276
if !chan.features.requires_unknown_bits() {
1277-
if let Some((directed_channel, source)) = chan.as_directed_to(&$node_id) {
1278-
if first_hops.is_none() || *source != our_node_id {
1279-
if directed_channel.direction().enabled {
1280-
let candidate = CandidateRouteHop::PublicHop {
1281-
info: directed_channel,
1282-
short_channel_id: *chan_id,
1283-
};
1284-
add_entry!(candidate, *source, $node_id,
1285-
$fee_to_target_msat,
1286-
$next_hops_value_contribution,
1287-
$next_hops_path_htlc_minimum_msat,
1288-
$next_hops_path_penalty_msat,
1289-
$next_hops_cltv_delta, $next_hops_path_length);
1277+
// We consider channels with only one direction filled useless,
1278+
// so we should check that both directions are present.
1279+
if chan.as_directed_from(&$node_id).is_some() {
1280+
if let Some((directed_channel, source)) = chan.as_directed_to(&$node_id) {
1281+
if first_hops.is_none() || *source != our_node_id {
1282+
if directed_channel.direction().enabled {
1283+
let candidate = CandidateRouteHop::PublicHop {
1284+
info: directed_channel,
1285+
short_channel_id: *chan_id,
1286+
};
1287+
add_entry!(candidate, *source, $node_id,
1288+
$fee_to_target_msat,
1289+
$next_hops_value_contribution,
1290+
$next_hops_path_htlc_minimum_msat,
1291+
$next_hops_path_penalty_msat,
1292+
$next_hops_cltv_delta, $next_hops_path_length);
1293+
}
12901294
}
12911295
}
12921296
}

0 commit comments

Comments
 (0)