Clean up code DRY'd in previous commit.
authorValentine Wallace <vwallace@protonmail.com>
Wed, 10 Jan 2024 16:19:09 +0000 (11:19 -0500)
committerValentine Wallace <vwallace@protonmail.com>
Wed, 10 Jan 2024 16:19:09 +0000 (11:19 -0500)
lightning/src/ln/channel.rs

index 72d3a402f63f7c209b20da420366ac1a922dd5e7..a3b2f74d1db39a1aab8125c15e824ef504004272 100644 (file)
@@ -3629,23 +3629,22 @@ impl<SP: Deref> Channel<SP> where
                                                 .map(|fail_msg_opt| fail_msg_opt.map(|_| ())))
                                        }
                                };
-                               match fail_htlc_res {
-                                       Some(Ok(fail_msg_opt)) => {
-                                               // If an HTLC failure was previously added to the holding cell (via
-                                               // `queue_fail_{malformed_}htlc`) then generating the fail message itself must
-                                               // not fail - we should never end up in a state where we double-fail
-                                               // an HTLC or fail-then-claim an HTLC as it indicates we didn't wait
-                                               // for a full revocation before failing.
-                                               debug_assert!(fail_msg_opt.is_some());
-                                               update_fail_count += 1;
-                                       },
-                                       Some(Err(e)) => {
-                                               if let ChannelError::Ignore(_) = e {}
-                                               else {
+                               if let Some(res) = fail_htlc_res {
+                                       match res {
+                                               Ok(fail_msg_opt) => {
+                                                       // If an HTLC failure was previously added to the holding cell (via
+                                                       // `queue_fail_{malformed_}htlc`) then generating the fail message itself must
+                                                       // not fail - we should never end up in a state where we double-fail
+                                                       // an HTLC or fail-then-claim an HTLC as it indicates we didn't wait
+                                                       // for a full revocation before failing.
+                                                       debug_assert!(fail_msg_opt.is_some());
+                                                       update_fail_count += 1;
+                                               },
+                                               Err(ChannelError::Ignore(_)) => {},
+                                               Err(_) => {
                                                        panic!("Got a non-IgnoreError action trying to fail holding cell HTLC");
-                                               }
-                                       },
-                                       None => {}
+                                               },
+                                       }
                                }
                        }
                        if update_add_count == 0 && update_fulfill_count == 0 && update_fail_count == 0 && self.context.holding_cell_update_fee.is_none() {