Skip to content

Commit f3db184

Browse files
committed
Add an operations section to ChannelManager docs
1 parent c39c398 commit f3db184

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,29 @@ where
12221222
/// # }
12231223
/// ```
12241224
///
1225+
/// # Operation
1226+
///
1227+
/// The following is required for [`ChannelManager`] to function properly:
1228+
/// - Handle messages from peers using its [`ChannelMessageHandler`] implementation (typically
1229+
/// called by [`PeerManager::read_event`] when processing network I/O)
1230+
/// - Send messages to peers obtained via its [`MessageSendEventsProvider`] implementation
1231+
/// (typically initiated when [`PeerManager::process_events`] is called)
1232+
/// - Feed on-chain activity using either its [`chain::Listen`] or [`chain::Confirm`] implementation
1233+
/// as documented by those traits
1234+
/// - Perform any periodic channel and payment checks by calling [`timer_tick_occurred`] roughly
1235+
/// every minute
1236+
/// - Persist to disk whenever [`get_and_clear_needs_persistence`] returns `true` using a
1237+
/// [`Persister`] such as a [`KVStore`] implementation
1238+
/// - Handle [`Event`]s obtained via its [`EventsProvider`] implementation
1239+
///
1240+
/// The [`Future`] returned by [`get_event_or_persistence_needed_future`] is useful in determining
1241+
/// when the last two requirements need to be checked.
1242+
///
1243+
/// The [`lightning-block-sync`] and [`lightning-transaction-sync`] crates provide utilities that
1244+
/// simplify feeding in on-chain activity using the [`chain::Listen`] and [`chain::Confirm`] traits,
1245+
/// respectively. The remaining requirements can be met using the [`lightning-background-processor`]
1246+
/// crate. For languages other than Rust, the availability of similar utilities may vary.
1247+
///
12251248
/// # Persistence
12261249
///
12271250
/// Implements [`Writeable`] to write out all channel state to disk. Implies [`peer_disconnected`] for
@@ -1273,13 +1296,22 @@ where
12731296
/// [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor
12741297
/// [`MessageHandler`]: crate::ln::peer_handler::MessageHandler
12751298
/// [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger
1299+
/// [`PeerManager::read_event`]: crate::ln::peer_handler::PeerManager::read_event
1300+
/// [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
1301+
/// [`timer_tick_occurred`]: Self::timer_tick_occurred
1302+
/// [`get_and_clear_needs_persistence`]: Self::get_and_clear_needs_persistence
1303+
/// [`Persister`]: crate::util::persist::Persister
1304+
/// [`KVStore`]: crate::util::persist::KVStore
1305+
/// [`get_event_or_persistence_needed_future`]: Self::get_event_or_persistence_needed_future
1306+
/// [`lightning-block-sync`]: https://docs.rs/lightning_block_sync/latest/lightning_block_sync
1307+
/// [`lightning-transaction-sync`]: https://docs.rs/lightning_transaction_sync/latest/lightning_transaction_sync
1308+
/// [`lightning-background-processor`]: https://docs.rs/lightning_background_processor/lightning_background_processor
12761309
/// [`peer_disconnected`]: msgs::ChannelMessageHandler::peer_disconnected
12771310
/// [`funding_created`]: msgs::FundingCreated
12781311
/// [`funding_transaction_generated`]: Self::funding_transaction_generated
12791312
/// [`BlockHash`]: bitcoin::hash_types::BlockHash
12801313
/// [`update_channel`]: chain::Watch::update_channel
12811314
/// [`ChannelUpdate`]: msgs::ChannelUpdate
1282-
/// [`timer_tick_occurred`]: Self::timer_tick_occurred
12831315
/// [`read`]: ReadableArgs::read
12841316
//
12851317
// Lock order:
@@ -8879,6 +8911,9 @@ where
88798911
}
88808912

88818913
/// Returns true if this [`ChannelManager`] needs to be persisted.
8914+
///
8915+
/// See [`Self::get_event_or_persistence_needed_future`] for retrieving a [`Future`] that
8916+
/// indicates this should be checked.
88828917
pub fn get_and_clear_needs_persistence(&self) -> bool {
88838918
self.needs_persist_flag.swap(false, Ordering::AcqRel)
88848919
}

0 commit comments

Comments
 (0)