@@ -1221,6 +1221,29 @@ where
1221
1221
/// # }
1222
1222
/// ```
1223
1223
///
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
+ ///
1224
1247
/// # Persistence
1225
1248
///
1226
1249
/// Implements [`Writeable`] to write out all channel state to disk. Implies [`peer_disconnected`] for
@@ -1272,13 +1295,22 @@ where
1272
1295
/// [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor
1273
1296
/// [`MessageHandler`]: crate::ln::peer_handler::MessageHandler
1274
1297
/// [`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
1275
1308
/// [`peer_disconnected`]: msgs::ChannelMessageHandler::peer_disconnected
1276
1309
/// [`funding_created`]: msgs::FundingCreated
1277
1310
/// [`funding_transaction_generated`]: Self::funding_transaction_generated
1278
1311
/// [`BlockHash`]: bitcoin::hash_types::BlockHash
1279
1312
/// [`update_channel`]: chain::Watch::update_channel
1280
1313
/// [`ChannelUpdate`]: msgs::ChannelUpdate
1281
- /// [`timer_tick_occurred`]: Self::timer_tick_occurred
1282
1314
/// [`read`]: ReadableArgs::read
1283
1315
//
1284
1316
// Lock order:
@@ -8878,6 +8910,9 @@ where
8878
8910
}
8879
8911
8880
8912
/// 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.
8881
8916
pub fn get_and_clear_needs_persistence(&self) -> bool {
8882
8917
self.needs_persist_flag.swap(false, Ordering::AcqRel)
8883
8918
}
0 commit comments