Rename `PersistenceNotifier` to simply `Notifier`
authorMatt Corallo <git@bluematt.me>
Fri, 12 Aug 2022 23:53:50 +0000 (23:53 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 12 Aug 2022 23:55:28 +0000 (23:55 +0000)
... as it is no longer persistence-specific (though still only used
for persistence).

lightning/src/ln/channelmanager.rs
lightning/src/util/wakers.rs

index 577c3d82cfe2ef82167ed97367e0fa2ffdab1cc3..3279050a079840a05bdc7ee1c4b97c8f2ddf6ed3 100644 (file)
@@ -55,7 +55,7 @@ use util::config::{UserConfig, ChannelConfig};
 use util::events::{EventHandler, EventsProvider, MessageSendEvent, MessageSendEventsProvider, ClosureReason, HTLCDestination};
 use util::{byte_utils, events};
 use util::crypto::sign;
-use util::wakers::PersistenceNotifier;
+use util::wakers::Notifier;
 use util::scid_utils::fake_scid;
 use util::ser::{BigSize, FixedLengthReader, Readable, ReadableArgs, MaybeReadable, Writeable, Writer, VecWriter};
 use util::logger::{Level, Logger};
@@ -790,10 +790,10 @@ pub struct ChannelManager<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
        /// Taken first everywhere where we are making changes before any other locks.
        /// When acquiring this lock in read mode, rather than acquiring it directly, call
        /// `PersistenceNotifierGuard::notify_on_drop(..)` and pass the lock to it, to ensure the
-       /// PersistenceNotifier the lock contains sends out a notification when the lock is released.
+       /// Notifier the lock contains sends out a notification when the lock is released.
        total_consistency_lock: RwLock<()>,
 
-       persistence_notifier: PersistenceNotifier,
+       persistence_notifier: Notifier,
 
        keys_manager: K,
 
@@ -833,18 +833,18 @@ enum NotifyOption {
 /// notify or not based on whether relevant changes have been made, providing a closure to
 /// `optionally_notify` which returns a `NotifyOption`.
 struct PersistenceNotifierGuard<'a, F: Fn() -> NotifyOption> {
-       persistence_notifier: &'a PersistenceNotifier,
+       persistence_notifier: &'a Notifier,
        should_persist: F,
        // We hold onto this result so the lock doesn't get released immediately.
        _read_guard: RwLockReadGuard<'a, ()>,
 }
 
 impl<'a> PersistenceNotifierGuard<'a, fn() -> NotifyOption> { // We don't care what the concrete F is here, it's unused
-       fn notify_on_drop(lock: &'a RwLock<()>, notifier: &'a PersistenceNotifier) -> PersistenceNotifierGuard<'a, impl Fn() -> NotifyOption> {
+       fn notify_on_drop(lock: &'a RwLock<()>, notifier: &'a Notifier) -> PersistenceNotifierGuard<'a, impl Fn() -> NotifyOption> {
                PersistenceNotifierGuard::optionally_notify(lock, notifier, || -> NotifyOption { NotifyOption::DoPersist })
        }
 
-       fn optionally_notify<F: Fn() -> NotifyOption>(lock: &'a RwLock<()>, notifier: &'a PersistenceNotifier, persist_check: F) -> PersistenceNotifierGuard<'a, F> {
+       fn optionally_notify<F: Fn() -> NotifyOption>(lock: &'a RwLock<()>, notifier: &'a Notifier, persist_check: F) -> PersistenceNotifierGuard<'a, F> {
                let read_guard = lock.read().unwrap();
 
                PersistenceNotifierGuard {
@@ -1625,7 +1625,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
                        pending_events: Mutex::new(Vec::new()),
                        pending_background_events: Mutex::new(Vec::new()),
                        total_consistency_lock: RwLock::new(()),
-                       persistence_notifier: PersistenceNotifier::new(),
+                       persistence_notifier: Notifier::new(),
 
                        keys_manager,
 
@@ -7240,7 +7240,7 @@ impl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
                        pending_events: Mutex::new(pending_events_read),
                        pending_background_events: Mutex::new(pending_background_events_read),
                        total_consistency_lock: RwLock::new(()),
-                       persistence_notifier: PersistenceNotifier::new(),
+                       persistence_notifier: Notifier::new(),
 
                        keys_manager: args.keys_manager,
                        logger: args.logger,
index ba218e4e1f53ca10701e3e7b93ffcf6d5059d45d..1532133eeda6052a9d7090ea64ff52be28927773 100644 (file)
@@ -22,13 +22,13 @@ use std::time::Instant;
 
 /// Used to signal to the ChannelManager persister that the manager needs to be re-persisted to
 /// disk/backups, through `await_persistable_update_timeout` and `await_persistable_update`.
-pub(crate) struct PersistenceNotifier {
+pub(crate) struct Notifier {
        /// Users won't access the persistence_lock directly, but rather wait on its bool using
        /// `wait_timeout` and `wait`.
        persistence_lock: (Mutex<bool>, Condvar),
 }
 
-impl PersistenceNotifier {
+impl Notifier {
        pub(crate) fn new() -> Self {
                Self {
                        persistence_lock: (Mutex::new(false), Condvar::new()),
@@ -108,7 +108,7 @@ mod tests {
                use core::sync::atomic::{AtomicBool, Ordering};
                use std::thread;
 
-               let persistence_notifier = Arc::new(PersistenceNotifier::new());
+               let persistence_notifier = Arc::new(Notifier::new());
                let thread_notifier = Arc::clone(&persistence_notifier);
 
                let exit_thread = Arc::new(AtomicBool::new(false));
@@ -129,7 +129,7 @@ mod tests {
                // Check that we can block indefinitely until updates are available.
                let _ = persistence_notifier.wait();
 
-               // Check that the PersistenceNotifier will return after the given duration if updates are
+               // Check that the Notifier will return after the given duration if updates are
                // available.
                loop {
                        if persistence_notifier.wait_timeout(Duration::from_millis(100)) {
@@ -139,7 +139,7 @@ mod tests {
 
                exit_thread.store(true, Ordering::SeqCst);
 
-               // Check that the PersistenceNotifier will return after the given duration even if no updates
+               // Check that the Notifier will return after the given duration even if no updates
                // are available.
                loop {
                        if !persistence_notifier.wait_timeout(Duration::from_millis(100)) {