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