Skip to content

Commit a90efee

Browse files
committed
Add an operations section to ChannelManager docs
1 parent 122f15f commit a90efee

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

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

0 commit comments

Comments
 (0)