Remove unnecessary `per_peer_state` branch
authorViktor Tigerström <11711198+ViktorTigerstrom@users.noreply.github.com>
Fri, 10 Jun 2022 00:01:36 +0000 (02:01 +0200)
committerViktor Tigerström <11711198+ViktorTigerstrom@users.noreply.github.com>
Mon, 9 Jan 2023 22:50:41 +0000 (23:50 +0100)
After `channels` are now stored in the `per_peer_state`, some logic can
be simplified and extra accessing of the `per_peer_state` can be
removed.

lightning/src/ln/channelmanager.rs

index 0a88f97e5f6160d29d686b0a633f31db593459a2..7b2865bb1475c6e80f96b4859a9eafa10116c839 100644 (file)
@@ -1590,7 +1590,7 @@ where
                                                channel_id: (*channel_id).clone(),
                                                counterparty: ChannelCounterparty {
                                                        node_id: channel.get_counterparty_node_id(),
-                                                       features: InitFeatures::empty(),
+                                                       features: peer_state.latest_features.clone(),
                                                        unspendable_punishment_reserve: to_remote_reserve_satoshis,
                                                        forwarding_info: channel.counterparty_forwarding_info(),
                                                        // Ensures that we have actually received the `htlc_minimum_msat` value
@@ -1630,12 +1630,6 @@ where
                                }
                        }
                }
-               let per_peer_state = self.per_peer_state.read().unwrap();
-               for chan in res.iter_mut() {
-                       if let Some(peer_state) = per_peer_state.get(&chan.counterparty.node_id) {
-                               chan.counterparty.features = peer_state.lock().unwrap().latest_features.clone();
-                       }
-               }
                res
        }