]> git.bitcoin.ninja Git - rust-lightning/commitdiff
f readability improvements from val 2021-09-multihop-route-hint-fix
authorMatt Corallo <git@bluematt.me>
Wed, 29 Sep 2021 23:16:22 +0000 (23:16 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 29 Sep 2021 23:16:22 +0000 (23:16 +0000)
lightning/src/routing/router.rs

index 38dc918d48c8cb7311f09fbfccbf217e2bd60f8b..57e604993cc3ca07a13f031548631478149cf9e2 100644 (file)
@@ -1031,19 +1031,20 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, paye
                                                        }
                                                }
                                        }
-                                       if features_set {
-                                       } else if let Some(node) = network_nodes.get(&ordered_hops.last().unwrap().0.pubkey) {
-                                               if let Some(node_info) = node.announcement_info.as_ref() {
-                                                       ordered_hops.last_mut().unwrap().1 = node_info.features.clone();
+                                       if !features_set {
+                                               if let Some(node) = network_nodes.get(&ordered_hops.last().unwrap().0.pubkey) {
+                                                       if let Some(node_info) = node.announcement_info.as_ref() {
+                                                               ordered_hops.last_mut().unwrap().1 = node_info.features.clone();
+                                                       } else {
+                                                               ordered_hops.last_mut().unwrap().1 = NodeFeatures::empty();
+                                                       }
                                                } else {
-                                                       ordered_hops.last_mut().unwrap().1 = NodeFeatures::empty();
+                                                       // We should be able to fill in features for everything except the last
+                                                       // hop, if the last hop was provided via a BOLT 11 invoice (though we
+                                                       // should be able to extend it further as BOLT 11 does have feature
+                                                       // flags for the last hop node itself).
+                                                       assert!(ordered_hops.last().unwrap().0.pubkey == *payee);
                                                }
-                                       } else {
-                                               // We should be able to fill in features for everything except the last
-                                               // hop, if the last hop was provided via a BOLT 11 invoice (though we
-                                               // should be able to extend it further as BOLT 11 does have feature
-                                               // flags for the last hop node itself).
-                                               assert!(ordered_hops.last().unwrap().0.pubkey == *payee);
                                        }
 
                                        // Means we succesfully traversed from the payer to the payee, now
@@ -4279,7 +4280,6 @@ mod tests {
                        assert_eq!(route.paths[1][0].short_channel_id, 2);
                        assert_eq!(route.paths[1][0].fee_msat, 50_000);
                }
-
        }
 
        #[test]