+/// Chain-related parameters used to construct a new `ChannelManager`.
+///
+/// Typically, the block-specific parameters are derived from the best block hash for the network,
+/// as a newly constructed `ChannelManager` will not have created any channels yet. These parameters
+/// are not needed when deserializing a previously constructed `ChannelManager`.
+pub struct ChainParameters {
+ /// The network for determining the `chain_hash` in Lightning messages.
+ pub network: Network,
+
+ /// The hash of the latest block successfully connected.
+ pub latest_hash: BlockHash,
+
+ /// The height of the latest block successfully connected.
+ ///
+ /// Used to track on-chain channel funding outputs and send payments with reliable timelocks.
+ pub latest_height: usize,
+}
+
+/// Whenever we release the `ChannelManager`'s `total_consistency_lock`, from read mode, it is
+/// desirable to notify any listeners on `await_persistable_update_timeout`/
+/// `await_persistable_update` that new updates are available for persistence. Therefore, this
+/// struct is responsible for locking the total consistency lock and, upon going out of scope,
+/// sending the aforementioned notification (since the lock being released indicates that the
+/// updates are ready for persistence).
+struct PersistenceNotifierGuard<'a> {
+ persistence_notifier: &'a PersistenceNotifier,
+ // We hold onto this result so the lock doesn't get released immediately.
+ _read_guard: RwLockReadGuard<'a, ()>,
+}
+
+impl<'a> PersistenceNotifierGuard<'a> {
+ fn new(lock: &'a RwLock<()>, notifier: &'a PersistenceNotifier) -> Self {
+ let read_guard = lock.read().unwrap();
+
+ Self {
+ persistence_notifier: notifier,
+ _read_guard: read_guard,
+ }
+ }
+}
+
+impl<'a> Drop for PersistenceNotifierGuard<'a> {
+ fn drop(&mut self) {
+ self.persistence_notifier.notify();
+ }
+}
+
+/// The amount of time in blocks we require our counterparty wait to claim their money (ie time
+/// between when we, or our watchtower, must check for them having broadcast a theft transaction).