@@ -498,8 +498,9 @@ struct ClaimablePayments {
498
498
}
499
499
500
500
/// Events which we process internally but cannot be procsesed immediately at the generation site
501
- /// for some reason. They are handled in timer_tick_occurred, so may be processed with
502
- /// quite some time lag.
501
+ /// usually because we're running pre-full-init. They are handled immediately once we detect we are
502
+ /// running normally, and specifically must be processed before any other non-background
503
+ /// [`ChannelMonitorUpdate`]s are applied.
503
504
enum BackgroundEvent {
504
505
/// Handle a ChannelMonitorUpdate which closes the channel. This is only separated from
505
506
/// [`Self::MonitorUpdateRegeneratedOnStartup`] as the non-closing variant needs a public key
@@ -984,6 +985,15 @@ where
984
985
pending_events : Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > > ,
985
986
/// A simple atomic flag to ensure only one task at a time can be processing events asynchronously.
986
987
pending_events_processor : AtomicBool ,
988
+
989
+ /// If we are running during init (either directly during the dserialization method or in block
990
+ /// connection methods which run after deserialization but before normal operation) we cannot
991
+ /// provide the user with [`ChannelMonitorUpdate`]s through the normal update flow - prior to
992
+ /// normal operation the user may not have loaded the [`ChannelMonitor`]s into their
993
+ /// [`ChainMonitor`] and thus attempting to update it will fail or panic.
994
+ ///
995
+ /// Thus, we place them here to be handled as soon as possible once we are running normally.
996
+ ///
987
997
/// See `ChannelManager` struct-level documentation for lock order requirements.
988
998
pending_background_events : Mutex < Vec < BackgroundEvent > > ,
989
999
/// Used when we have to take a BIG lock to make sure everything is self-consistent.
0 commit comments