Skip to content

Commit 8198628

Browse files
committed
Add an operations section to ChannelManager docs
1 parent 1b7c7cd commit 8198628

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,25 @@ where
11781178
///
11791179
/// TODO: Consider re-writing ChannelManagerReadArgs docs and moving here.
11801180
///
1181+
/// # Operation
1182+
///
1183+
/// The following is required for [`ChannelManager`] to function properly:
1184+
/// - Handle messages from peers using its [`ChannelMessageHandler`] implementation (typically
1185+
/// called by [`PeerManager::read_event`] when processing network I/O)
1186+
/// - Send messages to peers obtained via its [`MessageSendEventsProvider`] implementation
1187+
/// (typically initiated when [`PeerManager::process_events`] is called)
1188+
/// - Feed on-chain activity using either its [`chain::Listen`] or [`chain::Confirm`] implementation
1189+
/// as documented by those traits
1190+
/// - Perform any periodic channel and payment checks by calling [`timer_tick_occurred`] roughly
1191+
/// every minute
1192+
/// - Persist to disk whenever [`get_and_clear_needs_persistence`] returns `true` using a
1193+
/// [`Persister`] such as a [`KVStore`] implementation
1194+
///
1195+
/// The [`lightning-block-sync`] and [`lightning-transaction-sync`] crates provide utilities that
1196+
/// simplify feeding in on-chain activity using the [`chain::Listen`] and [`chain::Confirm`] traits,
1197+
/// respectively. The remaining requirements can be met using the [`lightning-background-processor`]
1198+
/// crate. For languages other than Rust, the availability of similar utilities may vary.
1199+
///
11811200
/// # Persistence
11821201
///
11831202
/// Implements [`Writeable`] to write out all channel state to disk. Implies [`peer_disconnected`] for
@@ -1227,13 +1246,21 @@ where
12271246
/// you're using lightning-net-tokio.
12281247
///
12291248
/// [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor
1249+
/// [`PeerManager::read_event`]: crate::ln::peer_handler::PeerManager::read_event
1250+
/// [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
1251+
/// [`timer_tick_occurred`]: Self::timer_tick_occurred
1252+
/// [`get_and_clear_needs_persistence`]: Self::get_and_clear_needs_persistence
1253+
/// [`Persister`]: crate::util::persist::Persister
1254+
/// [`KVStore`]: crate::util::persist::KVStore
1255+
/// [`lightning-block-sync`]: https://docs.rs/lightning_block_sync/latest/lightning_block_sync
1256+
/// [`lightning-transaction-sync`]: https://docs.rs/lightning_transaction_sync/latest/lightning_transaction_sync
1257+
/// [`lightning-background-processor`]: https://docs.rs/lightning_background_processor/lightning_background_processor
12301258
/// [`peer_disconnected`]: msgs::ChannelMessageHandler::peer_disconnected
12311259
/// [`funding_created`]: msgs::FundingCreated
12321260
/// [`funding_transaction_generated`]: Self::funding_transaction_generated
12331261
/// [`BlockHash`]: bitcoin::hash_types::BlockHash
12341262
/// [`update_channel`]: chain::Watch::update_channel
12351263
/// [`ChannelUpdate`]: msgs::ChannelUpdate
1236-
/// [`timer_tick_occurred`]: Self::timer_tick_occurred
12371264
/// [`read`]: ReadableArgs::read
12381265
//
12391266
// Lock order:
@@ -8648,6 +8675,9 @@ where
86488675
}
86498676

86508677
/// Returns true if this [`ChannelManager`] needs to be persisted.
8678+
///
8679+
/// See [`Self::get_event_or_persistence_needed_future`] for retrieving a [`Future`] that
8680+
/// indicates this should be checked.
86518681
pub fn get_and_clear_needs_persistence(&self) -> bool {
86528682
self.needs_persist_flag.swap(false, Ordering::AcqRel)
86538683
}

0 commit comments

Comments
 (0)