@@ -1000,6 +1000,9 @@ enum BackgroundEvent {
10001000 /// `counterparty_node_id` is not available as the channel has closed from a [`ChannelMonitor`]
10011001 /// error the other variant is acceptable.
10021002 ///
1003+ /// Any such events that exist in [`ChannelManager::pending_background_events`] will *also* be
1004+ /// tracked in [`PeerState::in_flight_monitor_updates`].
1005+ ///
10031006 /// Note that any such events are lost on shutdown, so in general they must be updates which
10041007 /// are regenerated on startup.
10051008 MonitorUpdateRegeneratedOnStartup {
@@ -1290,6 +1293,13 @@ pub(super) struct PeerState<SP: Deref> where SP::Target: SignerProvider {
12901293 /// Note that the channel may no longer exist. For example if the channel was closed but we
12911294 /// later needed to claim an HTLC which is pending on-chain, we may generate a monitor update
12921295 /// for a missing channel.
1296+ ///
1297+ /// Note that any pending [`BackgroundEvent::MonitorUpdateRegeneratedOnStartup`]s which are
1298+ /// sitting in [`ChannelManager::pending_background_events`] will *also* be tracked here. This
1299+ /// avoids a race condition during [`ChannelManager::pending_background_events`] processing
1300+ /// where we complete one [`ChannelMonitorUpdate`] (but there are more pending) but we conclude
1301+ /// all pending [`ChannelMonitorUpdate`]s have completed and its safe to run post-completion
1302+ /// actions.
12931303 in_flight_monitor_updates: BTreeMap<OutPoint, Vec<ChannelMonitorUpdate>>,
12941304 /// Map from a specific channel to some action(s) that should be taken when all pending
12951305 /// [`ChannelMonitorUpdate`]s for the channel complete updating.
0 commit comments