Skip to content

Commit 1055c80

Browse files
committed
Expand and format BackgroundProcessor docs
1 parent dc719c4 commit 1055c80

File tree

1 file changed

+27
-13
lines changed
  • lightning-background-processor/src

1 file changed

+27
-13
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,27 @@ use std::thread::JoinHandle;
2525
use std::time::{Duration, Instant};
2626
use std::ops::Deref;
2727

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
2929
/// Rust-Lightning running properly, and (2) either can or should be run in the background. Its
3030
/// 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,
3234
/// 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.
3738
///
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
4249
#[must_use = "BackgroundProcessor will immediately stop on drop. It should be stored until shutdown."]
4350
pub struct BackgroundProcessor {
4451
stop_thread: Arc<AtomicBool>,
@@ -92,15 +99,22 @@ impl BackgroundProcessor {
9299
/// `persist_manager` returns an error. In case of an error, the error is retrieved by calling
93100
/// either [`join`] or [`stop`].
94101
///
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
98103
///
99104
/// `persist_manager` is responsible for writing out the [`ChannelManager`] to disk, and/or
100105
/// uploading to one or more backup services. See [`ChannelManager::write`] for writing out a
101106
/// [`ChannelManager`]. See [`FilesystemPersister::persist_manager`] for Rust-Lightning's
102107
/// provided implementation.
103108
///
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+
///
104118
/// [top-level documentation]: Self
105119
/// [`join`]: Self::join
106120
/// [`stop`]: Self::stop

0 commit comments

Comments
 (0)