9
9
10
10
//! Logic to connect off-chain channel management with on-chain transaction monitoring.
11
11
//!
12
- //! [`ChainMonitor`] is a simple implementation of [`chain::Watch`] used both to process blocks and
13
- //! to update on-chain [`ChannelMonitor`]s accordingly. If any on-chain events need further
14
- //! processing, it will make those available as [`MonitorEvent`]s to be consumed.
12
+ //! [`ChainMonitor`] is an implementation of [`chain::Watch`] used both to process blocks and to
13
+ //! update [`ChannelMonitor`]s accordingly. If any on-chain events need further processing, it will
14
+ //! make those available as [`MonitorEvent`]s to be consumed.
15
+ //!
16
+ //! `ChainMonitor` is parameterized by an optional chain source, which must implement the
17
+ //! [`chain::Filter`] trait. This provides a mechanism to signal new relevant outputs back to light
18
+ //! clients, such that transactions spending those outputs are included in block data.
15
19
//!
16
20
//! `ChainMonitor` may be used directly to monitor channels locally or as a part of a distributed
17
21
//! setup to monitor channels remotely. In the latter case, a custom `chain::Watch` implementation
20
24
//! servicing `ChannelMonitor` updates from the client.
21
25
//!
22
26
//! [`ChainMonitor`]: struct.ChainMonitor.html
27
+ //! [`chain::Filter`]: ../trait.Filter.html
23
28
//! [`chain::Watch`]: ../trait.Watch.html
24
29
//! [`ChannelMonitor`]: ../channelmonitor/struct.ChannelMonitor.html
25
30
//! [`MonitorEvent`]: ../channelmonitor/enum.MonitorEvent.html
@@ -44,10 +49,12 @@ use std::ops::Deref;
44
49
///
45
50
/// Connected and disconnected blocks must be provided to `ChainMonitor` as documented by
46
51
/// [`chain::Watch`]. May be used in conjunction with [`ChannelManager`] to monitor channels locally
47
- /// or used independently to monitor channels remotely.
52
+ /// or used independently to monitor channels remotely. See the [module-level documentation] for
53
+ /// details.
48
54
///
49
55
/// [`chain::Watch`]: ../trait.Watch.html
50
56
/// [`ChannelManager`]: ../../ln/channelmanager/struct.ChannelManager.html
57
+ /// [module-level documentation]: index.html
51
58
pub struct ChainMonitor < ChanSigner : ChannelKeys , C : Deref , T : Deref , F : Deref , L : Deref >
52
59
where C :: Target : chain:: Filter ,
53
60
T :: Target : BroadcasterInterface ,
@@ -75,7 +82,7 @@ impl<ChanSigner: ChannelKeys, C: Deref, T: Deref, F: Deref, L: Deref> ChainMonit
75
82
///
76
83
/// Calls back to [`chain::Filter`] if any monitor indicated new outputs to watch, returning
77
84
/// `true` if so. In this case, if providing pre-filtered blocks, the caller should re-fetch the
78
- /// block to obtain updated `txdata` and recall `block_connected`.
85
+ /// block to obtain updated `txdata` and re-call `block_connected`.
79
86
///
80
87
/// [`ChannelMonitor::block_connected`]: ../channelmonitor/struct.ChannelMonitor.html#method.block_connected
81
88
/// [`chain::Watch::release_pending_monitor_events`]: ../trait.Watch.html#tymethod.release_pending_monitor_events
@@ -131,7 +138,7 @@ impl<ChanSigner: ChannelKeys, C: Deref, T: Deref, F: Deref, L: Deref> ChainMonit
131
138
}
132
139
}
133
140
134
- /// Adds or updates the monitor which monitors the channel referred to by the given outpoint.
141
+ /// Adds the monitor that watches the channel referred to by the given outpoint.
135
142
///
136
143
/// Calls back to [`chain::Filter`] with the funding transaction and outputs to watch.
137
144
///
@@ -159,7 +166,7 @@ impl<ChanSigner: ChannelKeys, C: Deref, T: Deref, F: Deref, L: Deref> ChainMonit
159
166
Ok ( ( ) )
160
167
}
161
168
162
- /// Updates the monitor which monitors the channel referred to by the given outpoint.
169
+ /// Updates the monitor that watches the channel referred to by the given outpoint.
163
170
fn update_monitor ( & self , outpoint : OutPoint , update : ChannelMonitorUpdate ) -> Result < ( ) , MonitorUpdateError > {
164
171
let mut monitors = self . monitors . lock ( ) . unwrap ( ) ;
165
172
match monitors. get_mut ( & outpoint) {
0 commit comments