@@ -248,12 +248,13 @@ const MULTI_STATE_FLAGS: u32 = BOTH_SIDES_SHUTDOWN_MASK | ChannelState::PeerDisc
248
248
249
249
pub const INITIAL_COMMITMENT_NUMBER : u64 = ( 1 << 48 ) - 1 ;
250
250
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.
254
255
/// See implementation at [`super::channelmanager::ChannelManager::timer_tick_occurred`].
255
256
#[ derive( Clone , Copy , PartialEq ) ]
256
- pub ( super ) enum UpdateStatus {
257
+ pub ( super ) enum ChannelUpdateStatus {
257
258
/// We've announced the channel as enabled and are connected to our peer.
258
259
Enabled ,
259
260
/// 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> {
418
419
419
420
commitment_secrets : CounterpartyCommitmentSecrets ,
420
421
421
- network_sync : UpdateStatus ,
422
+ channel_update_status : ChannelUpdateStatus ,
422
423
423
424
// We save these values so we can make sure `next_local_commit_tx_fee_msat` and
424
425
// `next_remote_commit_tx_fee_msat` properly predict what the next commitment transaction fee will
@@ -619,7 +620,7 @@ impl<Signer: Sign> Channel<Signer> {
619
620
620
621
commitment_secrets : CounterpartyCommitmentSecrets :: new ( ) ,
621
622
622
- network_sync : UpdateStatus :: Enabled ,
623
+ channel_update_status : ChannelUpdateStatus :: Enabled ,
623
624
624
625
#[ cfg( any( test, feature = "fuzztarget" ) ) ]
625
626
next_local_commitment_tx_fee_info_cached : Mutex :: new ( None ) ,
@@ -860,7 +861,7 @@ impl<Signer: Sign> Channel<Signer> {
860
861
861
862
commitment_secrets : CounterpartyCommitmentSecrets :: new ( ) ,
862
863
863
- network_sync : UpdateStatus :: Enabled ,
864
+ channel_update_status : ChannelUpdateStatus :: Enabled ,
864
865
865
866
#[ cfg( any( test, feature = "fuzztarget" ) ) ]
866
867
next_local_commitment_tx_fee_info_cached : Mutex :: new ( None ) ,
@@ -3497,12 +3498,12 @@ impl<Signer: Sign> Channel<Signer> {
3497
3498
} else { false }
3498
3499
}
3499
3500
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
3502
3503
}
3503
3504
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;
3506
3507
}
3507
3508
3508
3509
fn check_get_funding_locked ( & mut self , height : u32 ) -> Option < msgs:: FundingLocked > {
@@ -4365,26 +4366,26 @@ impl Readable for InboundHTLCRemovalReason {
4365
4366
}
4366
4367
}
4367
4368
4368
- impl Writeable for UpdateStatus {
4369
+ impl Writeable for ChannelUpdateStatus {
4369
4370
fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
4370
4371
// We only care about writing out the current state as it was announced, ie only either
4371
4372
// Enabled or Disabled. In the case of DisabledStaged, we most recently announced the
4372
4373
// channel as enabled, so we write 0. For EnabledStaged, we similarly write a 1.
4373
4374
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) ?,
4378
4379
}
4379
4380
Ok ( ( ) )
4380
4381
}
4381
4382
}
4382
4383
4383
- impl Readable for UpdateStatus {
4384
+ impl Readable for ChannelUpdateStatus {
4384
4385
fn read < R : :: std:: io:: Read > ( reader : & mut R ) -> Result < Self , DecodeError > {
4385
4386
Ok ( match <u8 as Readable >:: read ( reader) ? {
4386
- 0 => UpdateStatus :: Enabled ,
4387
- 1 => UpdateStatus :: Disabled ,
4387
+ 0 => ChannelUpdateStatus :: Enabled ,
4388
+ 1 => ChannelUpdateStatus :: Disabled ,
4388
4389
_ => return Err ( DecodeError :: InvalidValue ) ,
4389
4390
} )
4390
4391
}
@@ -4584,7 +4585,7 @@ impl<Signer: Sign> Writeable for Channel<Signer> {
4584
4585
4585
4586
self . commitment_secrets . write ( writer) ?;
4586
4587
4587
- self . network_sync . write ( writer) ?;
4588
+ self . channel_update_status . write ( writer) ?;
4588
4589
Ok ( ( ) )
4589
4590
}
4590
4591
}
@@ -4757,7 +4758,7 @@ impl<'a, Signer: Sign, K: Deref> ReadableArgs<&'a K> for Channel<Signer>
4757
4758
let counterparty_shutdown_scriptpubkey = Readable :: read ( reader) ?;
4758
4759
let commitment_secrets = Readable :: read ( reader) ?;
4759
4760
4760
- let network_sync = Readable :: read ( reader) ?;
4761
+ let channel_update_status = Readable :: read ( reader) ?;
4761
4762
4762
4763
let mut secp_ctx = Secp256k1 :: new ( ) ;
4763
4764
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>
4833
4834
4834
4835
commitment_secrets,
4835
4836
4836
- network_sync ,
4837
+ channel_update_status ,
4837
4838
4838
4839
#[ cfg( any( test, feature = "fuzztarget" ) ) ]
4839
4840
next_local_commitment_tx_fee_info_cached : Mutex :: new ( None ) ,
0 commit comments