struct PendingChannelMonitorUpdate {
update: ChannelMonitorUpdate,
- /// In some cases we need to delay letting the [`ChannelMonitorUpdate`] go until after an
- /// `Event` is processed by the user. This bool indicates the [`ChannelMonitorUpdate`] is
- /// blocked on some external event and the [`ChannelManager`] will update us when we're ready.
- ///
- /// [`ChannelManager`]: super::channelmanager::ChannelManager
- blocked: bool,
}
impl_writeable_tlv_based!(PendingChannelMonitorUpdate, {
(0, update, required),
- (2, blocked, required),
});
/// Contains everything about the channel including state, and various flags.
debug_assert!(false, "If there is a pending blocked monitor we should have MonitorUpdateInProgress set");
let update = self.build_commitment_no_status_check(logger);
self.context.pending_monitor_updates.push(PendingChannelMonitorUpdate {
- update, blocked: true,
+ update,
});
}
}
{
assert_eq!(self.context.channel_state & ChannelState::MonitorUpdateInProgress as u32, ChannelState::MonitorUpdateInProgress as u32);
self.context.channel_state &= !(ChannelState::MonitorUpdateInProgress as u32);
- for upd in self.context.pending_monitor_updates.iter() {
- debug_assert!(upd.blocked);
- }
// If we're past (or at) the FundingSent stage on an outbound channel, try to
// (re-)broadcast the funding transaction as we may have declined to broadcast it when we
/// Returns the next blocked monitor update, if one exists, and a bool which indicates a
/// further blocked monitor update exists after the next.
pub fn unblock_next_blocked_monitor_update(&mut self) -> Option<(ChannelMonitorUpdate, bool)> {
- for upd in self.context.pending_monitor_updates.iter() {
- debug_assert!(upd.blocked);
- }
if self.context.pending_monitor_updates.is_empty() { return None; }
Some((self.context.pending_monitor_updates.remove(0).update,
!self.context.pending_monitor_updates.is_empty()))
let release_monitor = self.context.pending_monitor_updates.is_empty();
if !release_monitor {
self.context.pending_monitor_updates.push(PendingChannelMonitorUpdate {
- update, blocked: true,
+ update,
});
None
} else {