Skip to content

Commit 8d2a85d

Browse files
committed
ninth
1 parent b913098 commit 8d2a85d

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

lightning/src/routing/router.rs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,27 +1243,23 @@ where L::Target: Logger {
12431243
// around again with a higher amount.
12441244
if !contributes_sufficient_value || exceeds_max_path_length ||
12451245
exceeds_cltv_delta_limit || payment_failed_on_this_channel {
1246-
let empty_vec: Vec<&ChannelDetails> = Vec::new();
1247-
let target = match first_hop_targets.get(&NodeId::from_pubkey(&our_node_pubkey)) {
1248-
Some(value) => value,
1249-
None => {
1250-
&empty_vec
1251-
}
1252-
};
1253-
for channel_details in target {
1254-
if let Some(short_channel_id_target) = channel_details.short_channel_id {
1255-
if short_channel_id == short_channel_id_target { // short_channel_id is hop id of candidate.
1256-
if !contributes_sufficient_value {
1257-
log_trace!(logger, "First Hop {short_channel_id} is excluded due to insufficient balance");
1258-
} else if exceeds_max_path_length {
1259-
log_trace!(logger, "First Hop {short_channel_id} is excluded due to candidate hop excluded max path length");
1260-
} else if exceeds_cltv_delta_limit {
1261-
log_trace!(logger, "First Hop {short_channel_id} is excluded beacause it exceed the maximum total cltv expiry limit");
1262-
} else if payment_failed_on_this_channel {
1263-
log_trace!(logger, "First Hop {short_channel_id} is excluded beacause it was failed previously");
1246+
let mut is_first_hop = true;
1247+
if let Some(target) = first_hop_targets.get(&NodeId::from_pubkey(&our_node_pubkey)){
1248+
for channel_details in target {
1249+
if let Some(short_channel_id_target) = channel_details.short_channel_id{
1250+
if short_channel_id_target == short_channel_id { // short_channel_id is hop id of candidate.
1251+
if is_first_hop && !contributes_sufficient_value {
1252+
log_trace!(logger, "First Hop {short_channel_id} is excluded due to insufficient value");
1253+
} else if is_first_hop && exceeds_max_path_length {
1254+
log_trace!(logger, "First Hop {short_channel_id} is excluded due to candidate hop excluded max path length");
1255+
} else if is_first_hop && exceeds_cltv_delta_limit {
1256+
log_trace!(logger, "First Hop {short_channel_id} is excluded beacause it exceed the maximum total cltv expiry limit");
1257+
} else if is_first_hop && payment_failed_on_this_channel {
1258+
log_trace!(logger, "First Hop {short_channel_id} is excluded beacause it was failed previously");
1259+
}
1260+
is_first_hop = false;
12641261
}
1265-
1266-
}
1262+
}
12671263
}
12681264
}
12691265
// Path isn't useful, ignore it and move on.

0 commit comments

Comments
 (0)