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