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