@@ -26,20 +26,27 @@ use std::thread::JoinHandle;
26
26
use std:: time:: { Duration , Instant } ;
27
27
use std:: ops:: Deref ;
28
28
29
- /// BackgroundProcessor takes care of tasks that (1) need to happen periodically to keep
29
+ /// ` BackgroundProcessor` takes care of tasks that (1) need to happen periodically to keep
30
30
/// Rust-Lightning running properly, and (2) either can or should be run in the background. Its
31
31
/// responsibilities are:
32
- /// * Monitoring whether the ChannelManager needs to be re-persisted to disk, and if so,
32
+ /// * Processing [`MessageSendEvent`]s by calling [`PeerManager::process_events`].
33
+ /// * Processing [`Event`]s with a user-provided [`EventHandler`].
34
+ /// * Monitoring whether the [`ChannelManager`] needs to be re-persisted to disk, and if so,
33
35
/// writing it to disk/backups by invoking the callback given to it at startup.
34
- /// ChannelManager persistence should be done in the background.
35
- /// * Calling `ChannelManager::timer_tick_occurred()` and
36
- /// `PeerManager::timer_tick_occurred()` every minute (can be done in the
37
- /// background).
36
+ /// [`ChannelManager`] persistence should be done in the background.
37
+ /// * Calling [`ChannelManager::timer_tick_occurred`] and [`PeerManager::timer_tick_occurred`]
38
+ /// at the appropriate intervals.
38
39
///
39
- /// Note that if ChannelManager persistence fails and the persisted manager becomes out-of-date,
40
- /// then there is a risk of channels force-closing on startup when the manager realizes it's
41
- /// outdated. However, as long as `ChannelMonitor` backups are sound, no funds besides those used
42
- /// for unilateral chain closure fees are at risk.
40
+ /// # Note
41
+ ///
42
+ /// If [`ChannelManager`] persistence fails and the persisted manager becomes out-of-date, then
43
+ /// there is a risk of channels force-closing on startup when the manager realizes it's outdated.
44
+ /// However, as long as [`ChannelMonitor`] backups are sound, no funds besides those used for
45
+ /// unilateral chain closure fees are at risk.
46
+ ///
47
+ /// [`ChannelMonitor`]: lightning::chain::channelmonitor::ChannelMonitor
48
+ /// [`Event`]: lightning::util::events::Event
49
+ /// [`MessageSendEvent`]: lightning::util::events::MessageSendEvent
43
50
#[ must_use = "BackgroundProcessor will immediately stop on drop. It should be stored until shutdown." ]
44
51
pub struct BackgroundProcessor {
45
52
stop_thread : Arc < AtomicBool > ,
@@ -99,15 +106,23 @@ impl BackgroundProcessor {
99
106
/// `persist_manager` returns an error. In case of an error, the error is retrieved by calling
100
107
/// either [`join`] or [`stop`].
101
108
///
102
- /// Typically, users should either implement [`ChannelManagerPersister`] to never return an
103
- /// error or call [`join`] and handle any error that may arise. For the latter case, the
104
- /// `BackgroundProcessor` must be restarted by calling `start` again after handling the error.
109
+ /// # Data Persistence
105
110
///
106
111
/// `persist_manager` is responsible for writing out the [`ChannelManager`] to disk, and/or
107
112
/// uploading to one or more backup services. See [`ChannelManager::write`] for writing out a
108
113
/// [`ChannelManager`]. See [`FilesystemPersister::persist_manager`] for Rust-Lightning's
109
114
/// provided implementation.
110
115
///
116
+ /// Typically, users should either implement [`ChannelManagerPersister`] to never return an
117
+ /// error or call [`join`] and handle any error that may arise. For the latter case,
118
+ /// `BackgroundProcessor` must be restarted by calling `start` again after handling the error.
119
+ ///
120
+ /// # Event Handling
121
+ ///
122
+ /// `event_handler` is responsible for handling events that users should be notified of (e.g.,
123
+ /// payment failed). A user's [`EventHandler`] may be decorated with other handlers to implement
124
+ /// common functionality. See individual [`Event`]s for further details.
125
+ ///
111
126
/// [top-level documentation]: Self
112
127
/// [`join`]: Self::join
113
128
/// [`stop`]: Self::stop
0 commit comments