Skip to content

Commit 631aa25

Browse files
committed
f clean up node skipping variables
1 parent aa9c2c2 commit 631aa25

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

lightning/src/routing/router.rs

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -751,9 +751,9 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
751751
macro_rules! add_entries_to_cheapest_to_target_node {
752752
( $node: expr, $node_id: expr, $fee_to_target_msat: expr, $next_hops_value_contribution: expr, $next_hops_path_htlc_minimum_msat: expr ) => {
753753
let skip_node = if let Some(elem) = dist.get_mut($node_id) {
754-
let v = elem.was_processed;
754+
let was_processed = elem.was_processed;
755755
elem.was_processed = true;
756-
v
756+
was_processed
757757
} else {
758758
// Entries are added to dist in add_entry!() when there is a channel from a node.
759759
// Because there are no channels from payee, it will not have a dist entry at this point.
@@ -762,40 +762,41 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
762762
false
763763
};
764764

765-
if !skip_node && first_hops.is_some() {
766-
if let Some(&(ref first_hop, ref features, ref outbound_capacity_msat)) = first_hop_targets.get(&$node_id) {
767-
add_entry!(first_hop, *our_node_id, $node_id, dummy_directional_info, Some(outbound_capacity_msat / 1000), features.to_context(), $fee_to_target_msat, $next_hops_value_contribution, $next_hops_path_htlc_minimum_msat);
765+
if !skip_node {
766+
if first_hops.is_some() {
767+
if let Some(&(ref first_hop, ref features, ref outbound_capacity_msat)) = first_hop_targets.get(&$node_id) {
768+
add_entry!(first_hop, *our_node_id, $node_id, dummy_directional_info, Some(outbound_capacity_msat / 1000), features.to_context(), $fee_to_target_msat, $next_hops_value_contribution, $next_hops_path_htlc_minimum_msat);
769+
}
768770
}
769-
}
770771

771-
let features;
772-
if let Some(node_info) = $node.announcement_info.as_ref() {
773-
features = node_info.features.clone();
774-
} else {
775-
features = NodeFeatures::empty();
776-
}
772+
let features;
773+
if let Some(node_info) = $node.announcement_info.as_ref() {
774+
features = node_info.features.clone();
775+
} else {
776+
features = NodeFeatures::empty();
777+
}
777778

778-
if !skip_node && !features.requires_unknown_bits() {
779-
for chan_id in $node.channels.iter() {
780-
let chan = network.get_channels().get(chan_id).unwrap();
781-
if !chan.features.requires_unknown_bits() {
782-
if chan.node_one == *$node_id {
783-
// ie $node is one, ie next hop in A* is two, via the two_to_one channel
784-
if first_hops.is_none() || chan.node_two != *our_node_id {
785-
if let Some(two_to_one) = chan.two_to_one.as_ref() {
786-
if two_to_one.enabled {
787-
add_entry!(chan_id, chan.node_two, chan.node_one, two_to_one, chan.capacity_sats, chan.features, $fee_to_target_msat, $next_hops_value_contribution, $next_hops_path_htlc_minimum_msat);
779+
if !features.requires_unknown_bits() {
780+
for chan_id in $node.channels.iter() {
781+
let chan = network.get_channels().get(chan_id).unwrap();
782+
if !chan.features.requires_unknown_bits() {
783+
if chan.node_one == *$node_id {
784+
// ie $node is one, ie next hop in A* is two, via the two_to_one channel
785+
if first_hops.is_none() || chan.node_two != *our_node_id {
786+
if let Some(two_to_one) = chan.two_to_one.as_ref() {
787+
if two_to_one.enabled {
788+
add_entry!(chan_id, chan.node_two, chan.node_one, two_to_one, chan.capacity_sats, chan.features, $fee_to_target_msat, $next_hops_value_contribution, $next_hops_path_htlc_minimum_msat);
789+
}
788790
}
789791
}
790-
}
791-
} else {
792-
if first_hops.is_none() || chan.node_one != *our_node_id {
793-
if let Some(one_to_two) = chan.one_to_two.as_ref() {
794-
if one_to_two.enabled {
795-
add_entry!(chan_id, chan.node_one, chan.node_two, one_to_two, chan.capacity_sats, chan.features, $fee_to_target_msat, $next_hops_value_contribution, $next_hops_path_htlc_minimum_msat);
792+
} else {
793+
if first_hops.is_none() || chan.node_one != *our_node_id {
794+
if let Some(one_to_two) = chan.one_to_two.as_ref() {
795+
if one_to_two.enabled {
796+
add_entry!(chan_id, chan.node_one, chan.node_two, one_to_two, chan.capacity_sats, chan.features, $fee_to_target_msat, $next_hops_value_contribution, $next_hops_path_htlc_minimum_msat);
797+
}
796798
}
797799
}
798-
799800
}
800801
}
801802
}

0 commit comments

Comments
 (0)