Skip to content

Commit 47e9ca1

Browse files
committed
Rename PersistenceNotifier to simply Notifier
... as it is no longer persistence-specific (though still only used for persistence).
1 parent 68b3d2e commit 47e9ca1

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ use util::config::{UserConfig, ChannelConfig};
5555
use util::events::{EventHandler, EventsProvider, MessageSendEvent, MessageSendEventsProvider, ClosureReason, HTLCDestination};
5656
use util::{byte_utils, events};
5757
use util::crypto::sign;
58-
use util::wakers::PersistenceNotifier;
58+
use util::wakers::Notifier;
5959
use util::scid_utils::fake_scid;
6060
use util::ser::{BigSize, FixedLengthReader, Readable, ReadableArgs, MaybeReadable, Writeable, Writer, VecWriter};
6161
use util::logger::{Level, Logger};
@@ -790,10 +790,10 @@ pub struct ChannelManager<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
790790
/// Taken first everywhere where we are making changes before any other locks.
791791
/// When acquiring this lock in read mode, rather than acquiring it directly, call
792792
/// `PersistenceNotifierGuard::notify_on_drop(..)` and pass the lock to it, to ensure the
793-
/// PersistenceNotifier the lock contains sends out a notification when the lock is released.
793+
/// Notifier the lock contains sends out a notification when the lock is released.
794794
total_consistency_lock: RwLock<()>,
795795

796-
persistence_notifier: PersistenceNotifier,
796+
persistence_notifier: Notifier,
797797

798798
keys_manager: K,
799799

@@ -833,18 +833,18 @@ enum NotifyOption {
833833
/// notify or not based on whether relevant changes have been made, providing a closure to
834834
/// `optionally_notify` which returns a `NotifyOption`.
835835
struct PersistenceNotifierGuard<'a, F: Fn() -> NotifyOption> {
836-
persistence_notifier: &'a PersistenceNotifier,
836+
persistence_notifier: &'a Notifier,
837837
should_persist: F,
838838
// We hold onto this result so the lock doesn't get released immediately.
839839
_read_guard: RwLockReadGuard<'a, ()>,
840840
}
841841

842842
impl<'a> PersistenceNotifierGuard<'a, fn() -> NotifyOption> { // We don't care what the concrete F is here, it's unused
843-
fn notify_on_drop(lock: &'a RwLock<()>, notifier: &'a PersistenceNotifier) -> PersistenceNotifierGuard<'a, impl Fn() -> NotifyOption> {
843+
fn notify_on_drop(lock: &'a RwLock<()>, notifier: &'a Notifier) -> PersistenceNotifierGuard<'a, impl Fn() -> NotifyOption> {
844844
PersistenceNotifierGuard::optionally_notify(lock, notifier, || -> NotifyOption { NotifyOption::DoPersist })
845845
}
846846

847-
fn optionally_notify<F: Fn() -> NotifyOption>(lock: &'a RwLock<()>, notifier: &'a PersistenceNotifier, persist_check: F) -> PersistenceNotifierGuard<'a, F> {
847+
fn optionally_notify<F: Fn() -> NotifyOption>(lock: &'a RwLock<()>, notifier: &'a Notifier, persist_check: F) -> PersistenceNotifierGuard<'a, F> {
848848
let read_guard = lock.read().unwrap();
849849

850850
PersistenceNotifierGuard {
@@ -1625,7 +1625,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
16251625
pending_events: Mutex::new(Vec::new()),
16261626
pending_background_events: Mutex::new(Vec::new()),
16271627
total_consistency_lock: RwLock::new(()),
1628-
persistence_notifier: PersistenceNotifier::new(),
1628+
persistence_notifier: Notifier::new(),
16291629

16301630
keys_manager,
16311631

@@ -7240,7 +7240,7 @@ impl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
72407240
pending_events: Mutex::new(pending_events_read),
72417241
pending_background_events: Mutex::new(pending_background_events_read),
72427242
total_consistency_lock: RwLock::new(()),
7243-
persistence_notifier: PersistenceNotifier::new(),
7243+
persistence_notifier: Notifier::new(),
72447244

72457245
keys_manager: args.keys_manager,
72467246
logger: args.logger,

lightning/src/util/wakers.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ use std::time::Instant;
2222

2323
/// Used to signal to the ChannelManager persister that the manager needs to be re-persisted to
2424
/// disk/backups, through `await_persistable_update_timeout` and `await_persistable_update`.
25-
pub(crate) struct PersistenceNotifier {
25+
pub(crate) struct Notifier {
2626
/// Users won't access the persistence_lock directly, but rather wait on its bool using
2727
/// `wait_timeout` and `wait`.
2828
persistence_lock: (Mutex<bool>, Condvar),
2929
}
3030

31-
impl PersistenceNotifier {
31+
impl Notifier {
3232
pub(crate) fn new() -> Self {
3333
Self {
3434
persistence_lock: (Mutex::new(false), Condvar::new()),
@@ -108,7 +108,7 @@ mod tests {
108108
use core::sync::atomic::{AtomicBool, Ordering};
109109
use std::thread;
110110

111-
let persistence_notifier = Arc::new(PersistenceNotifier::new());
111+
let persistence_notifier = Arc::new(Notifier::new());
112112
let thread_notifier = Arc::clone(&persistence_notifier);
113113

114114
let exit_thread = Arc::new(AtomicBool::new(false));
@@ -129,7 +129,7 @@ mod tests {
129129
// Check that we can block indefinitely until updates are available.
130130
let _ = persistence_notifier.wait();
131131

132-
// Check that the PersistenceNotifier will return after the given duration if updates are
132+
// Check that the Notifier will return after the given duration if updates are
133133
// available.
134134
loop {
135135
if persistence_notifier.wait_timeout(Duration::from_millis(100)) {
@@ -139,7 +139,7 @@ mod tests {
139139

140140
exit_thread.store(true, Ordering::SeqCst);
141141

142-
// Check that the PersistenceNotifier will return after the given duration even if no updates
142+
// Check that the Notifier will return after the given duration even if no updates
143143
// are available.
144144
loop {
145145
if !persistence_notifier.wait_timeout(Duration::from_millis(100)) {

0 commit comments

Comments
 (0)