@@ -188,7 +188,13 @@ pub trait Confirm {
188
188
189
189
/// An error enum representing a failure to persist a channel monitor update.
190
190
#[ 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 ,
192
198
/// Used to indicate a temporary failure (eg connection to a watchtower or remote backup of
193
199
/// our state failed, but is expected to succeed at some point in the future).
194
200
///
@@ -211,11 +217,12 @@ pub enum ChannelMonitorUpdateErr {
211
217
///
212
218
/// For deployments where a copy of ChannelMonitors and other local state are backed up in a
213
219
/// 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.
215
221
///
216
- /// [`PermanentFailure`]: ChannelMonitorUpdateErr::PermanentFailure
222
+ /// [`PermanentFailure`]: ChannelMonitorUpdateResult::PermanentFailure
223
+ /// [`UpdateInProgress`]: ChannelMonitorUpdateResult::UpdateInProgress
217
224
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
218
- TemporaryFailure ,
225
+ UpdateInProgress ,
219
226
/// Used to indicate no further channel monitor updates will be allowed (likely a disk failure
220
227
/// or a remote copy of this [`ChannelMonitor`] is no longer reachable and thus not updatable).
221
228
///
@@ -252,7 +259,7 @@ pub enum ChannelMonitorUpdateErr {
252
259
/// storage is used to claim outputs of rejected state confirmed onchain by another watchtower,
253
260
/// lagging behind on block processing.
254
261
///
255
- /// [`PermanentFailure`]: ChannelMonitorUpdateErr ::PermanentFailure
262
+ /// [`PermanentFailure`]: ChannelMonitorUpdateResult ::PermanentFailure
256
263
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
257
264
PermanentFailure ,
258
265
}
@@ -272,32 +279,32 @@ pub enum ChannelMonitorUpdateErr {
272
279
/// If an implementation maintains multiple instances of a channel's monitor (e.g., by storing
273
280
/// backup copies), then it must ensure that updates are applied across all instances. Otherwise, it
274
281
/// 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
276
283
/// multiple instances.
277
284
///
278
- /// [`PermanentFailure`]: ChannelMonitorUpdateErr ::PermanentFailure
285
+ /// [`PermanentFailure`]: ChannelMonitorUpdateResult ::PermanentFailure
279
286
pub trait Watch < ChannelSigner : Sign > {
280
287
/// Watches a channel identified by `funding_txo` using `monitor`.
281
288
///
282
289
/// Implementations are responsible for watching the chain for the funding transaction along
283
290
/// with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means
284
291
/// calling [`block_connected`] and [`block_disconnected`] on the monitor.
285
292
///
286
- /// Note: this interface MUST error with [`ChannelMonitorUpdateErr ::PermanentFailure`] if
293
+ /// Note: this interface MUST error with [`ChannelMonitorUpdateResult ::PermanentFailure`] if
287
294
/// the given `funding_txo` has previously been registered via `watch_channel`.
288
295
///
289
296
/// [`get_outputs_to_watch`]: channelmonitor::ChannelMonitor::get_outputs_to_watch
290
297
/// [`block_connected`]: channelmonitor::ChannelMonitor::block_connected
291
298
/// [`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 ;
293
300
294
301
/// Updates a channel identified by `funding_txo` by applying `update` to its monitor.
295
302
///
296
303
/// 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.
298
305
///
299
306
/// [`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 ;
301
308
302
309
/// Returns any monitor events since the last call. Subsequent calls must only return new
303
310
/// events.
@@ -307,7 +314,7 @@ pub trait Watch<ChannelSigner: Sign> {
307
314
/// to disk.
308
315
///
309
316
/// For details on asynchronous [`ChannelMonitor`] updating and returning
310
- /// [`MonitorEvent::UpdateCompleted`] here, see [`ChannelMonitorUpdateErr::TemporaryFailure `].
317
+ /// [`MonitorEvent::UpdateCompleted`] here, see [`ChannelMonitorUpdateResult::UpdateInProgress `].
311
318
fn release_pending_monitor_events ( & self ) -> Vec < ( OutPoint , Vec < MonitorEvent > ) > ;
312
319
}
313
320
@@ -326,9 +333,9 @@ pub trait Watch<ChannelSigner: Sign> {
326
333
/// Note that use as part of a [`Watch`] implementation involves reentrancy. Therefore, the `Filter`
327
334
/// should not block on I/O. Implementations should instead queue the newly monitored data to be
328
335
/// 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 `].
330
337
///
331
- /// [`TemporaryFailure `]: ChannelMonitorUpdateErr::TemporaryFailure
338
+ /// [`UpdateInProgress `]: ChannelMonitorUpdateResult::UpdateInProgress
332
339
/// [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki
333
340
/// [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki
334
341
pub trait Filter {
0 commit comments