]> git.bitcoin.ninja Git - rust-lightning/commitdiff
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)
committerMatt Corallo <git@bluematt.me>
Mon, 9 Jan 2023 19:42:52 +0000 (19:42 +0000)
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 cda6fbbea992b23b8f5aa5a28aff5ed29504f0d6..beccaf005be63909f06c8333df0b5ba692671658 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
        }