@@ -210,6 +210,20 @@ const MULTI_STATE_FLAGS: u32 = (BOTH_SIDES_SHUTDOWN_MASK | ChannelState::PeerDis
210
210
211
211
const INITIAL_COMMITMENT_NUMBER : u64 = ( 1 << 48 ) - 1 ;
212
212
213
+ /// Liveness is called to fluctuate given peer disconnecton/monitor failures/closing.
214
+ /// If channel is public, network should have a liveness view announced by us on a
215
+ /// best-effort, which means we may filter out some status transitions to avoid spam.
216
+ /// See further timer_chan_freshness_every_min.
217
+ #[ derive( PartialEq ) ]
218
+ enum UpdateStatus {
219
+ /// Status has been gossiped.
220
+ Fresh ,
221
+ /// Status has been changed.
222
+ DisabledMarked ,
223
+ /// Status has been marked to be gossiped at next flush
224
+ DisabledStaged ,
225
+ }
226
+
213
227
// TODO: We should refactor this to be an Inbound/OutboundChannel until initial setup handshaking
214
228
// has been completed, and then turn into a Channel to get compiler-time enforcement of things like
215
229
// calling channel_id() before we're set up or things like get_outbound_funding_signed on an
@@ -340,6 +354,8 @@ pub(super) struct Channel {
340
354
341
355
channel_monitor : ChannelMonitor ,
342
356
357
+ network_sync : UpdateStatus ,
358
+
343
359
logger : Arc < Logger > ,
344
360
}
345
361
@@ -517,6 +533,8 @@ impl Channel {
517
533
518
534
channel_monitor : channel_monitor,
519
535
536
+ network_sync : UpdateStatus :: Fresh ,
537
+
520
538
logger,
521
539
} )
522
540
}
@@ -734,6 +752,8 @@ impl Channel {
734
752
735
753
channel_monitor : channel_monitor,
736
754
755
+ network_sync : UpdateStatus :: Fresh ,
756
+
737
757
logger,
738
758
} ;
739
759
@@ -2993,6 +3013,26 @@ impl Channel {
2993
3013
} else { false }
2994
3014
}
2995
3015
3016
+ pub fn to_disabled_staged ( & mut self ) {
3017
+ self . network_sync = UpdateStatus :: DisabledStaged ;
3018
+ }
3019
+
3020
+ pub fn to_disabled_marked ( & mut self ) {
3021
+ self . network_sync = UpdateStatus :: DisabledMarked ;
3022
+ }
3023
+
3024
+ pub fn to_fresh ( & mut self ) {
3025
+ self . network_sync = UpdateStatus :: Fresh ;
3026
+ }
3027
+
3028
+ pub fn is_disabled_staged ( & self ) -> bool {
3029
+ self . network_sync == UpdateStatus :: DisabledStaged
3030
+ }
3031
+
3032
+ pub fn is_disabled_marked ( & self ) -> bool {
3033
+ self . network_sync == UpdateStatus :: DisabledMarked
3034
+ }
3035
+
2996
3036
/// Called by channelmanager based on chain blocks being connected.
2997
3037
/// Note that we only need to use this to detect funding_signed, anything else is handled by
2998
3038
/// the channel_monitor.
@@ -4091,6 +4131,8 @@ impl<R : ::std::io::Read> ReadableArgs<R, Arc<Logger>> for Channel {
4091
4131
4092
4132
channel_monitor,
4093
4133
4134
+ network_sync : UpdateStatus :: Fresh ,
4135
+
4094
4136
logger,
4095
4137
} )
4096
4138
}
0 commit comments