@@ -248,12 +248,13 @@ const MULTI_STATE_FLAGS: u32 = BOTH_SIDES_SHUTDOWN_MASK | ChannelState::PeerDisc
248248
249249pub const INITIAL_COMMITMENT_NUMBER : u64 = ( 1 << 48 ) - 1 ;
250250
251- /// Liveness is called to fluctuate given peer disconnecton/monitor failures/closing.
252- /// If channel is public, network should have a liveness view announced by us on a
253- /// best-effort, which means we may filter out some status transitions to avoid spam.
251+ /// The "channel disabled" bit in channel_update must be set based on whether we are connected to
252+ /// our counterparty or not. However, we don't want to announce updates right away to avoid
253+ /// spamming the network with updates if the connection is flapping. Instead, we "stage" updates to
254+ /// our channel_update message and track the current state here.
254255/// See implementation at [`super::channelmanager::ChannelManager::timer_tick_occurred`].
255256#[ derive( Clone , Copy , PartialEq ) ]
256- pub ( super ) enum UpdateStatus {
257+ pub ( super ) enum ChannelUpdateStatus {
257258 /// We've announced the channel as enabled and are connected to our peer.
258259 Enabled ,
259260 /// Our channel is no longer live, but we haven't announced the channel as disabled yet.
@@ -418,7 +419,7 @@ pub(super) struct Channel<Signer: Sign> {
418419
419420 commitment_secrets : CounterpartyCommitmentSecrets ,
420421
421- network_sync : UpdateStatus ,
422+ channel_update_status : ChannelUpdateStatus ,
422423
423424 // We save these values so we can make sure `next_local_commit_tx_fee_msat` and
424425 // `next_remote_commit_tx_fee_msat` properly predict what the next commitment transaction fee will
@@ -619,7 +620,7 @@ impl<Signer: Sign> Channel<Signer> {
619620
620621 commitment_secrets : CounterpartyCommitmentSecrets :: new ( ) ,
621622
622- network_sync : UpdateStatus :: Enabled ,
623+ channel_update_status : ChannelUpdateStatus :: Enabled ,
623624
624625 #[ cfg( any( test, feature = "fuzztarget" ) ) ]
625626 next_local_commitment_tx_fee_info_cached : Mutex :: new ( None ) ,
@@ -860,7 +861,7 @@ impl<Signer: Sign> Channel<Signer> {
860861
861862 commitment_secrets : CounterpartyCommitmentSecrets :: new ( ) ,
862863
863- network_sync : UpdateStatus :: Enabled ,
864+ channel_update_status : ChannelUpdateStatus :: Enabled ,
864865
865866 #[ cfg( any( test, feature = "fuzztarget" ) ) ]
866867 next_local_commitment_tx_fee_info_cached : Mutex :: new ( None ) ,
@@ -3497,12 +3498,12 @@ impl<Signer: Sign> Channel<Signer> {
34973498 } else { false }
34983499 }
34993500
3500- pub fn get_update_status ( & self ) -> UpdateStatus {
3501- self . network_sync
3501+ pub fn channel_update_status ( & self ) -> ChannelUpdateStatus {
3502+ self . channel_update_status
35023503 }
35033504
3504- pub fn set_update_status ( & mut self , status : UpdateStatus ) {
3505- self . network_sync = status;
3505+ pub fn set_channel_update_status ( & mut self , status : ChannelUpdateStatus ) {
3506+ self . channel_update_status = status;
35063507 }
35073508
35083509 fn check_get_funding_locked ( & mut self , height : u32 ) -> Option < msgs:: FundingLocked > {
@@ -4365,26 +4366,26 @@ impl Readable for InboundHTLCRemovalReason {
43654366 }
43664367}
43674368
4368- impl Writeable for UpdateStatus {
4369+ impl Writeable for ChannelUpdateStatus {
43694370 fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
43704371 // We only care about writing out the current state as it was announced, ie only either
43714372 // Enabled or Disabled. In the case of DisabledStaged, we most recently announced the
43724373 // channel as enabled, so we write 0. For EnabledStaged, we similarly write a 1.
43734374 match self {
4374- UpdateStatus :: Enabled => 0u8 . write ( writer) ?,
4375- UpdateStatus :: DisabledStaged => 0u8 . write ( writer) ?,
4376- UpdateStatus :: EnabledStaged => 1u8 . write ( writer) ?,
4377- UpdateStatus :: Disabled => 1u8 . write ( writer) ?,
4375+ ChannelUpdateStatus :: Enabled => 0u8 . write ( writer) ?,
4376+ ChannelUpdateStatus :: DisabledStaged => 0u8 . write ( writer) ?,
4377+ ChannelUpdateStatus :: EnabledStaged => 1u8 . write ( writer) ?,
4378+ ChannelUpdateStatus :: Disabled => 1u8 . write ( writer) ?,
43784379 }
43794380 Ok ( ( ) )
43804381 }
43814382}
43824383
4383- impl Readable for UpdateStatus {
4384+ impl Readable for ChannelUpdateStatus {
43844385 fn read < R : :: std:: io:: Read > ( reader : & mut R ) -> Result < Self , DecodeError > {
43854386 Ok ( match <u8 as Readable >:: read ( reader) ? {
4386- 0 => UpdateStatus :: Enabled ,
4387- 1 => UpdateStatus :: Disabled ,
4387+ 0 => ChannelUpdateStatus :: Enabled ,
4388+ 1 => ChannelUpdateStatus :: Disabled ,
43884389 _ => return Err ( DecodeError :: InvalidValue ) ,
43894390 } )
43904391 }
@@ -4584,7 +4585,7 @@ impl<Signer: Sign> Writeable for Channel<Signer> {
45844585
45854586 self . commitment_secrets . write ( writer) ?;
45864587
4587- self . network_sync . write ( writer) ?;
4588+ self . channel_update_status . write ( writer) ?;
45884589 Ok ( ( ) )
45894590 }
45904591}
@@ -4757,7 +4758,7 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<&'a K> for Channel<Signer>
47574758 let counterparty_shutdown_scriptpubkey = Readable :: read ( reader) ?;
47584759 let commitment_secrets = Readable :: read ( reader) ?;
47594760
4760- let network_sync = Readable :: read ( reader) ?;
4761+ let channel_update_status = Readable :: read ( reader) ?;
47614762
47624763 let mut secp_ctx = Secp256k1 :: new ( ) ;
47634764 secp_ctx. seeded_randomize ( & keys_source. get_secure_random_bytes ( ) ) ;
@@ -4833,7 +4834,7 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<&'a K> for Channel<Signer>
48334834
48344835 commitment_secrets,
48354836
4836- network_sync ,
4837+ channel_update_status ,
48374838
48384839 #[ cfg( any( test, feature = "fuzztarget" ) ) ]
48394840 next_local_commitment_tx_fee_info_cached : Mutex :: new ( None ) ,
0 commit comments