]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Remove unnecessary channel counterparty checks
authorViktor Tigerström <11711198+ViktorTigerstrom@users.noreply.github.com>
Sat, 10 Dec 2022 17:03:22 +0000 (18:03 +0100)
committerViktor Tigerström <11711198+ViktorTigerstrom@users.noreply.github.com>
Mon, 9 Jan 2023 22:50:41 +0000 (23:50 +0100)
lightning/src/ln/channelmanager.rs

index 8dc45684640a709f87ff14a588c0f9fd07c315ee..ca912702379b4496a42d32078c2d7b75e9712826 100644 (file)
@@ -6037,15 +6037,13 @@ where
                                let mut peer_state_lock = peer_state_mutex.lock().unwrap();
                                let peer_state = &mut *peer_state_lock;
                                peer_state.channel_by_id.retain(|_, chan| {
-                                       if chan.get_counterparty_node_id() == *counterparty_node_id {
-                                               chan.remove_uncommitted_htlcs_and_mark_paused(&self.logger);
-                                               if chan.is_shutdown() {
-                                                       update_maps_on_chan_removal!(self, chan);
-                                                       self.issue_channel_close_events(chan, ClosureReason::DisconnectedPeer);
-                                                       return false;
-                                               } else {
-                                                       no_channels_remain = false;
-                                               }
+                                       chan.remove_uncommitted_htlcs_and_mark_paused(&self.logger);
+                                       if chan.is_shutdown() {
+                                               update_maps_on_chan_removal!(self, chan);
+                                               self.issue_channel_close_events(chan, ClosureReason::DisconnectedPeer);
+                                               return false;
+                                       } else {
+                                               no_channels_remain = false;
                                        }
                                        true
                                });
@@ -6171,9 +6169,6 @@ where
                                        let mut peer_state_lock = peer_state_mutex.lock().unwrap();
                                        let peer_state = &mut *peer_state_lock;
                                        if let Some(chan) = peer_state.channel_by_id.get_mut(&msg.channel_id) {
-                                               if chan.get_counterparty_node_id() != *counterparty_node_id {
-                                                       return;
-                                               }
                                                if let Ok(msg) = chan.maybe_handle_error_without_close(self.genesis_hash) {
                                                        channel_state.pending_msg_events.push(events::MessageSendEvent::SendOpenChannel {
                                                                node_id: *counterparty_node_id,