Skip to content

Commit ee64281

Browse files
committed
f clean up node skipping variables
1 parent 9083ef6 commit ee64281

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
@@ -748,9 +748,9 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
748748
macro_rules! add_entries_to_cheapest_to_target_node {
749749
( $node: expr, $node_id: expr, $fee_to_target_msat: expr, $next_hops_value_contribution: expr, $incl_fee_next_hops_htlc_minimum_msat: expr ) => {
750750
let skip_node = if let Some(elem) = dist.get_mut($node_id) {
751-
let v = elem.was_processed;
751+
let was_processed = elem.was_processed;
752752
elem.was_processed = true;
753-
v
753+
was_processed
754754
} else {
755755
// Entries are added to dist in add_entry!() when there is a channel from a node.
756756
// Because there are no channels from payee, it will not have a dist entry at this point.
@@ -759,40 +759,41 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
759759
false
760760
};
761761

762-
if !skip_node && first_hops.is_some() {
763-
if let Some(&(ref first_hop, ref features, ref outbound_capacity_msat)) = first_hop_targets.get(&$node_id) {
764-
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, $incl_fee_next_hops_htlc_minimum_msat);
762+
if !skip_node {
763+
if first_hops.is_some() {
764+
if let Some(&(ref first_hop, ref features, ref outbound_capacity_msat)) = first_hop_targets.get(&$node_id) {
765+
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, $incl_fee_next_hops_htlc_minimum_msat);
766+
}
765767
}
766-
}
767768

768-
let features;
769-
if let Some(node_info) = $node.announcement_info.as_ref() {
770-
features = node_info.features.clone();
771-
} else {
772-
features = NodeFeatures::empty();
773-
}
769+
let features;
770+
if let Some(node_info) = $node.announcement_info.as_ref() {
771+
features = node_info.features.clone();
772+
} else {
773+
features = NodeFeatures::empty();
774+
}
774775

775-
if !skip_node && !features.requires_unknown_bits() {
776-
for chan_id in $node.channels.iter() {
777-
let chan = network.get_channels().get(chan_id).unwrap();
778-
if !chan.features.requires_unknown_bits() {
779-
if chan.node_one == *$node_id {
780-
// ie $node is one, ie next hop in A* is two, via the two_to_one channel
781-
if first_hops.is_none() || chan.node_two != *our_node_id {
782-
if let Some(two_to_one) = chan.two_to_one.as_ref() {
783-
if two_to_one.enabled {
784-
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, $incl_fee_next_hops_htlc_minimum_msat);
776+
if !features.requires_unknown_bits() {
777+
for chan_id in $node.channels.iter() {
778+
let chan = network.get_channels().get(chan_id).unwrap();
779+
if !chan.features.requires_unknown_bits() {
780+
if chan.node_one == *$node_id {
781+
// ie $node is one, ie next hop in A* is two, via the two_to_one channel
782+
if first_hops.is_none() || chan.node_two != *our_node_id {
783+
if let Some(two_to_one) = chan.two_to_one.as_ref() {
784+
if two_to_one.enabled {
785+
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, $incl_fee_next_hops_htlc_minimum_msat);
786+
}
785787
}
786788
}
787-
}
788-
} else {
789-
if first_hops.is_none() || chan.node_one != *our_node_id {
790-
if let Some(one_to_two) = chan.one_to_two.as_ref() {
791-
if one_to_two.enabled {
792-
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, $incl_fee_next_hops_htlc_minimum_msat);
789+
} else {
790+
if first_hops.is_none() || chan.node_one != *our_node_id {
791+
if let Some(one_to_two) = chan.one_to_two.as_ref() {
792+
if one_to_two.enabled {
793+
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, $incl_fee_next_hops_htlc_minimum_msat);
794+
}
793795
}
794796
}
795-
796797
}
797798
}
798799
}

0 commit comments

Comments
 (0)