Remove unnecessary match expressions
authorJeffrey Czyz <jkczyz@gmail.com>
Mon, 24 Jan 2022 04:44:42 +0000 (22:44 -0600)
committerJeffrey Czyz <jkczyz@gmail.com>
Tue, 25 Jan 2022 17:42:29 +0000 (11:42 -0600)
lightning/src/routing/router.rs

index 45244f53e26171f8cd88d0795dcc0ad3ee6a164d..3c682c0ea7452354850f36ce353ed058735aae47 100644 (file)
@@ -967,33 +967,25 @@ where L::Target: Logger {
                                                        // Ignore hop_use_fee_msat for channel-from-us as we assume all channels-from-us
                                                        // will have the same effective-fee
                                                        if $src_node_id != our_node_id {
-                                                               match compute_fees(amount_to_transfer_over_msat, $candidate.fees()) {
-                                                                       // max_value means we'll always fail
-                                                                       // the old_entry.total_fee_msat > total_fee_msat check
-                                                                       None => total_fee_msat = u64::max_value(),
-                                                                       Some(fee_msat) => {
+                                                               total_fee_msat = compute_fees(amount_to_transfer_over_msat, $candidate.fees())
+                                                                       .and_then(|fee_msat| {
                                                                                hop_use_fee_msat = fee_msat;
                                                                                total_fee_msat += hop_use_fee_msat;
-                                                                               // When calculating the lowest inbound fees to a node, we
-                                                                               // calculate fees here not based on the actual value we think
-                                                                               // will flow over this channel, but on the minimum value that
-                                                                               // we'll accept flowing over it. The minimum accepted value
-                                                                               // is a constant through each path collection run, ensuring
-                                                                               // consistent basis. Otherwise we may later find a
-                                                                               // different path to the source node that is more expensive,
-                                                                               // but which we consider to be cheaper because we are capacity
-                                                                               // constrained and the relative fee becomes lower.
-                                                                               match compute_fees(minimal_value_contribution_msat, old_entry.src_lowest_inbound_fees)
-                                                                                               .map(|a| a.checked_add(total_fee_msat)) {
-                                                                                       Some(Some(v)) => {
-                                                                                               total_fee_msat = v;
-                                                                                       },
-                                                                                       _ => {
-                                                                                               total_fee_msat = u64::max_value();
-                                                                                       }
-                                                                               };
-                                                                       }
-                                                               }
+                                                                               compute_fees(minimal_value_contribution_msat, old_entry.src_lowest_inbound_fees)
+                                                                       })
+                                                                       // When calculating the lowest inbound fees to a node, we
+                                                                       // calculate fees here not based on the actual value we think
+                                                                       // will flow over this channel, but on the minimum value that
+                                                                       // we'll accept flowing over it. The minimum accepted value
+                                                                       // is a constant through each path collection run, ensuring
+                                                                       // consistent basis. Otherwise we may later find a
+                                                                       // different path to the source node that is more expensive,
+                                                                       // but which we consider to be cheaper because we are capacity
+                                                                       // constrained and the relative fee becomes lower.
+                                                                       .and_then(|a| a.checked_add(total_fee_msat))
+                                                                       // max_value means we'll always fail
+                                                                       // the old_entry.total_fee_msat > total_fee_msat check
+                                                                       .unwrap_or_else(|| u64::max_value());
                                                        }
 
                                                        let effective_capacity_msat = $candidate.effective_capacity().as_msat();