]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Avoid slices without inner references in channelmanager
authorMatt Corallo <git@bluematt.me>
Thu, 28 Sep 2023 03:05:09 +0000 (03:05 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 3 Oct 2023 23:23:16 +0000 (23:23 +0000)
lightning/src/ln/channelmanager.rs

index defc5b76d74036ed84ebba897fd00b4fb93b5923..a9aa14704dacd6b507910930e1eb963686b7205e 100644 (file)
@@ -3982,7 +3982,7 @@ where
        /// [`ChannelUnavailable`]: APIError::ChannelUnavailable
        /// [`APIMisuseError`]: APIError::APIMisuseError
        pub fn update_partial_channel_config(
-               &self, counterparty_node_id: &PublicKey, channel_ids: &[ChannelId], config_update: &ChannelConfigUpdate,
+               &self, counterparty_node_id: &PublicKey, channel_ids: Vec<ChannelId>, config_update: &ChannelConfigUpdate,
        ) -> Result<(), APIError> {
                if config_update.cltv_expiry_delta.map(|delta| delta < MIN_CLTV_EXPIRY_DELTA).unwrap_or(false) {
                        return Err(APIError::APIMisuseError {
@@ -3996,14 +3996,14 @@ where
                        .ok_or_else(|| APIError::ChannelUnavailable { err: format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id) })?;
                let mut peer_state_lock = peer_state_mutex.lock().unwrap();
                let peer_state = &mut *peer_state_lock;
-               for channel_id in channel_ids {
+               for channel_id in channel_ids.iter() {
                        if !peer_state.has_channel(channel_id) {
                                return Err(APIError::ChannelUnavailable {
                                        err: format!("Channel with ID {} was not found for the passed counterparty_node_id {}", channel_id, counterparty_node_id),
                                });
                        };
                }
-               for channel_id in channel_ids {
+               for channel_id in channel_ids.iter() {
                        if let Some(channel_phase) = peer_state.channel_by_id.get_mut(channel_id) {
                                let mut config = channel_phase.context().config();
                                config.apply(config_update);
@@ -4057,7 +4057,7 @@ where
        /// [`ChannelUnavailable`]: APIError::ChannelUnavailable
        /// [`APIMisuseError`]: APIError::APIMisuseError
        pub fn update_channel_config(
-               &self, counterparty_node_id: &PublicKey, channel_ids: &[ChannelId], config: &ChannelConfig,
+               &self, counterparty_node_id: &PublicKey, channel_ids: Vec<ChannelId>, config: &ChannelConfig,
        ) -> Result<(), APIError> {
                return self.update_partial_channel_config(counterparty_node_id, channel_ids, &(*config).into());
        }