@@ -188,7 +188,13 @@ pub trait Confirm {
188188
189189/// An error enum representing a failure to persist a channel monitor update.
190190#[ derive( Clone , Copy , Debug , PartialEq ) ]
191- pub enum ChannelMonitorUpdateErr {
191+ pub enum ChannelMonitorUpdateResult {
192+ /// The update has been durably persisted and all copies of the relevant [`ChannelMonitor`]
193+ /// have been updated.
194+ ///
195+ /// This includes performing any `fsync()` calls required to ensure the update is guaranteed to
196+ /// be available on restart even if the application crashes.
197+ UpdateComplete ,
192198 /// Used to indicate a temporary failure (eg connection to a watchtower or remote backup of
193199 /// our state failed, but is expected to succeed at some point in the future).
194200 ///
@@ -211,11 +217,12 @@ pub enum ChannelMonitorUpdateErr {
211217 ///
212218 /// For deployments where a copy of ChannelMonitors and other local state are backed up in a
213219 /// remote location (with local copies persisted immediately), it is anticipated that all
214- /// updates will return TemporaryFailure until the remote copies could be updated.
220+ /// updates will return [`UpdateInProgress`] until the remote copies could be updated.
215221 ///
216- /// [`PermanentFailure`]: ChannelMonitorUpdateErr::PermanentFailure
222+ /// [`PermanentFailure`]: ChannelMonitorUpdateResult::PermanentFailure
223+ /// [`UpdateInProgress`]: ChannelMonitorUpdateResult::UpdateInProgress
217224 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
218- TemporaryFailure ,
225+ UpdateInProgress ,
219226 /// Used to indicate no further channel monitor updates will be allowed (likely a disk failure
220227 /// or a remote copy of this [`ChannelMonitor`] is no longer reachable and thus not updatable).
221228 ///
@@ -252,7 +259,7 @@ pub enum ChannelMonitorUpdateErr {
252259 /// storage is used to claim outputs of rejected state confirmed onchain by another watchtower,
253260 /// lagging behind on block processing.
254261 ///
255- /// [`PermanentFailure`]: ChannelMonitorUpdateErr ::PermanentFailure
262+ /// [`PermanentFailure`]: ChannelMonitorUpdateResult ::PermanentFailure
256263 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
257264 PermanentFailure ,
258265}
@@ -272,32 +279,32 @@ pub enum ChannelMonitorUpdateErr {
272279/// If an implementation maintains multiple instances of a channel's monitor (e.g., by storing
273280/// backup copies), then it must ensure that updates are applied across all instances. Otherwise, it
274281/// could result in a revoked transaction being broadcast, allowing the counterparty to claim all
275- /// funds in the channel. See [`ChannelMonitorUpdateErr `] for more details about how to handle
282+ /// funds in the channel. See [`ChannelMonitorUpdateResult `] for more details about how to handle
276283/// multiple instances.
277284///
278- /// [`PermanentFailure`]: ChannelMonitorUpdateErr ::PermanentFailure
285+ /// [`PermanentFailure`]: ChannelMonitorUpdateResult ::PermanentFailure
279286pub trait Watch < ChannelSigner : Sign > {
280287 /// Watches a channel identified by `funding_txo` using `monitor`.
281288 ///
282289 /// Implementations are responsible for watching the chain for the funding transaction along
283290 /// with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means
284291 /// calling [`block_connected`] and [`block_disconnected`] on the monitor.
285292 ///
286- /// Note: this interface MUST error with [`ChannelMonitorUpdateErr ::PermanentFailure`] if
293+ /// Note: this interface MUST error with [`ChannelMonitorUpdateResult ::PermanentFailure`] if
287294 /// the given `funding_txo` has previously been registered via `watch_channel`.
288295 ///
289296 /// [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch
290297 /// [`block_connected`]: channelmonitor::ChannelMonitor::block_connected
291298 /// [`block_disconnected`]: channelmonitor::ChannelMonitor::block_disconnected
292- fn watch_channel ( & self , funding_txo : OutPoint , monitor : ChannelMonitor < ChannelSigner > ) -> Result < ( ) , ChannelMonitorUpdateErr > ;
299+ fn watch_channel ( & self , funding_txo : OutPoint , monitor : ChannelMonitor < ChannelSigner > ) -> ChannelMonitorUpdateResult ;
293300
294301 /// Updates a channel identified by `funding_txo` by applying `update` to its monitor.
295302 ///
296303 /// Implementations must call [`update_monitor`] with the given update. See
297- /// [`ChannelMonitorUpdateErr `] for invariants around returning an error.
304+ /// [`ChannelMonitorUpdateResult `] for invariants around returning an error.
298305 ///
299306 /// [`update_monitor`]: channelmonitor::ChannelMonitor::update_monitor
300- fn update_channel ( & self , funding_txo : OutPoint , update : ChannelMonitorUpdate ) -> Result < ( ) , ChannelMonitorUpdateErr > ;
307+ fn update_channel ( & self , funding_txo : OutPoint , update : ChannelMonitorUpdate ) -> ChannelMonitorUpdateResult ;
301308
302309 /// Returns any monitor events since the last call. Subsequent calls must only return new
303310 /// events.
@@ -307,7 +314,7 @@ pub trait Watch<ChannelSigner: Sign> {
307314 /// to disk.
308315 ///
309316 /// For details on asynchronous [`ChannelMonitor`] updating and returning
310- /// [`MonitorEvent::UpdateCompleted`] here, see [`ChannelMonitorUpdateErr::TemporaryFailure `].
317+ /// [`MonitorEvent::UpdateCompleted`] here, see [`ChannelMonitorUpdateResult::UpdateInProgress `].
311318 fn release_pending_monitor_events ( & self ) -> Vec < ( OutPoint , Vec < MonitorEvent > ) > ;
312319}
313320
@@ -326,9 +333,9 @@ pub trait Watch<ChannelSigner: Sign> {
326333/// Note that use as part of a [`Watch`] implementation involves reentrancy. Therefore, the `Filter`
327334/// should not block on I/O. Implementations should instead queue the newly monitored data to be
328335/// processed later. Then, in order to block until the data has been processed, any [`Watch`]
329- /// invocation that has called the `Filter` must return [`TemporaryFailure `].
336+ /// invocation that has called the `Filter` must return [`UpdateInProgress `].
330337///
331- /// [`TemporaryFailure `]: ChannelMonitorUpdateErr::TemporaryFailure
338+ /// [`UpdateInProgress `]: ChannelMonitorUpdateResult::UpdateInProgress
332339/// [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki
333340/// [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki
334341pub trait Filter {
0 commit comments