]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Merge pull request #2691 from wpaulino/refactor-channel-state
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Thu, 7 Dec 2023 23:59:13 +0000 (23:59 +0000)
committerGitHub <noreply@github.com>
Thu, 7 Dec 2023 23:59:13 +0000 (23:59 +0000)
Refactor ChannelState to decouple state flags from states

1  2 
lightning/src/ln/channel.rs

index 117986acf1010cc2e08c2f210be05ff97aad0ab5,5a49b6807ba62434f27d671717b7bcab6444273e..8d6144fc25f9c3ed4a123c77406cc43b6ca4924f
@@@ -2789,13 -3018,13 +3017,13 @@@ impl<SP: Deref> Channel<SP> wher
                        self.context.counterparty_cur_commitment_point.unwrap(),
                        counterparty_initial_commitment_tx.feerate_per_kw(),
                        counterparty_initial_commitment_tx.to_broadcaster_value_sat(),
 -                      counterparty_initial_commitment_tx.to_countersignatory_value_sat(), &&logger_with_chan_monitor);
 +                      counterparty_initial_commitment_tx.to_countersignatory_value_sat(), logger);
  
-               assert_eq!(self.context.channel_state & (ChannelState::MonitorUpdateInProgress as u32), 0); // We have no had any monitor(s) yet to fail update!
+               assert!(!self.context.channel_state.is_monitor_update_in_progress()); // We have no had any monitor(s) yet to fail update!
                if self.context.is_batch_funding() {
-                       self.context.channel_state = ChannelState::FundingSent as u32 | ChannelState::WaitingForBatch as u32;
+                       self.context.channel_state = ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::WAITING_FOR_BATCH);
                } else {
-                       self.context.channel_state = ChannelState::FundingSent as u32;
+                       self.context.channel_state = ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
                }
                self.context.cur_holder_commitment_transaction_number -= 1;
                self.context.cur_counterparty_commitment_transaction_number -= 1;