Skip to content

Commit 6da0e06

Browse files
committed
access hashmap
1 parent 8d2a85d commit 6da0e06

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

lightning/src/routing/router.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,21 +1244,24 @@ where L::Target: Logger {
12441244
if !contributes_sufficient_value || exceeds_max_path_length ||
12451245
exceeds_cltv_delta_limit || payment_failed_on_this_channel {
12461246
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");
1247+
// if let Some(target) = first_hop_targets.get(&NodeId::from_pubkey(&our_node_pubkey)) {
1248+
for (key ,value) in &first_hop_targets {
1249+
if (key == &NodeId::from_pubkey(&our_node_pubkey)) {
1250+
for channel_details in value {
1251+
if let Some(short_channel_id_target) = channel_details.short_channel_id{
1252+
if short_channel_id_target == short_channel_id { // short_channel_id is hop id of candidate.
1253+
if is_first_hop && !contributes_sufficient_value {
1254+
log_trace!(logger, "First Hop {short_channel_id} is excluded due to insufficient value");
1255+
} else if is_first_hop && exceeds_max_path_length {
1256+
log_trace!(logger, "First Hop {short_channel_id} is excluded due to candidate hop excluded max path length");
1257+
} else if is_first_hop && exceeds_cltv_delta_limit {
1258+
log_trace!(logger, "First Hop {short_channel_id} is excluded beacause it exceed the maximum total cltv expiry limit");
1259+
} else if is_first_hop && payment_failed_on_this_channel {
1260+
log_trace!(logger, "First Hop {short_channel_id} is excluded beacause it was failed previously");
1261+
}
1262+
is_first_hop = false;
12591263
}
1260-
is_first_hop = false;
1261-
}
1264+
}
12621265
}
12631266
}
12641267
}

0 commit comments

Comments
 (0)