@@ -1249,11 +1249,12 @@ impl<'a> PersistenceNotifierGuard<'a, fn() -> NotifyOption> { // We don't care w
1249
1249
1250
1250
/// Note that if any [`ChannelMonitorUpdate`]s are possibly generated,
1251
1251
/// [`ChannelManager::process_background_events`] MUST be called first.
1252
- fn optionally_notify<F: Fn() -> NotifyOption>(lock: &'a RwLock<()>, notifier: &'a Notifier, persist_check: F) -> PersistenceNotifierGuard<'a, F> {
1253
- let read_guard = lock.read().unwrap();
1252
+ fn optionally_notify<F: Fn() -> NotifyOption, C: AChannelManager>(cm: &'a C, persist_check: F)
1253
+ -> PersistenceNotifierGuard<'a, F> {
1254
+ let read_guard = cm.get_cm().total_consistency_lock.read().unwrap();
1254
1255
1255
1256
PersistenceNotifierGuard {
1256
- event_persist_notifier: notifier ,
1257
+ event_persist_notifier: &cm.get_cm().event_persist_notifier ,
1257
1258
should_persist: persist_check,
1258
1259
_read_guard: read_guard,
1259
1260
}
@@ -4422,7 +4423,7 @@ where
4422
4423
/// these a fuzz failure (as they usually indicate a channel force-close, which is exactly what
4423
4424
/// it wants to detect). Thus, we have a variant exposed here for its benefit.
4424
4425
pub fn maybe_update_chan_fees(&self) {
4425
- PersistenceNotifierGuard::optionally_notify(& self.total_consistency_lock, &self.event_persist_notifier , || {
4426
+ PersistenceNotifierGuard::optionally_notify(self, || {
4426
4427
let mut should_persist = self.process_background_events();
4427
4428
4428
4429
let normal_feerate = self.fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Normal);
@@ -4467,7 +4468,7 @@ where
4467
4468
/// [`ChannelUpdate`]: msgs::ChannelUpdate
4468
4469
/// [`ChannelConfig`]: crate::util::config::ChannelConfig
4469
4470
pub fn timer_tick_occurred(&self) {
4470
- PersistenceNotifierGuard::optionally_notify(& self.total_consistency_lock, &self.event_persist_notifier , || {
4471
+ PersistenceNotifierGuard::optionally_notify(self, || {
4471
4472
let mut should_persist = self.process_background_events();
4472
4473
4473
4474
let normal_feerate = self.fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Normal);
@@ -7000,7 +7001,7 @@ where
7000
7001
/// the `MessageSendEvent`s to the specific peer they were generated under.
7001
7002
fn get_and_clear_pending_msg_events(&self) -> Vec<MessageSendEvent> {
7002
7003
let events = RefCell::new(Vec::new());
7003
- PersistenceNotifierGuard::optionally_notify(& self.total_consistency_lock, &self.event_persist_notifier , || {
7004
+ PersistenceNotifierGuard::optionally_notify(self, || {
7004
7005
let mut result = self.process_background_events();
7005
7006
7006
7007
// TODO: This behavior should be documented. It's unintuitive that we query
@@ -7082,8 +7083,8 @@ where
7082
7083
}
7083
7084
7084
7085
fn block_disconnected(&self, header: &BlockHeader, height: u32) {
7085
- let _persistence_guard = PersistenceNotifierGuard::optionally_notify(& self.total_consistency_lock ,
7086
- &self.event_persist_notifier, || -> NotifyOption { NotifyOption::DoPersist });
7086
+ let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self,
7087
+ || -> NotifyOption { NotifyOption::DoPersist });
7087
7088
let new_height = height - 1;
7088
7089
{
7089
7090
let mut best_block = self.best_block.write().unwrap();
@@ -7117,8 +7118,8 @@ where
7117
7118
let block_hash = header.block_hash();
7118
7119
log_trace!(self.logger, "{} transactions included in block {} at height {} provided", txdata.len(), block_hash, height);
7119
7120
7120
- let _persistence_guard = PersistenceNotifierGuard::optionally_notify(& self.total_consistency_lock ,
7121
- &self.event_persist_notifier, || -> NotifyOption { NotifyOption::DoPersist });
7121
+ let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self,
7122
+ || -> NotifyOption { NotifyOption::DoPersist });
7122
7123
self.do_chain_event(Some(height), |channel| channel.transactions_confirmed(&block_hash, height, txdata, self.genesis_hash.clone(), &self.node_signer, &self.default_configuration, &self.logger)
7123
7124
.map(|(a, b)| (a, Vec::new(), b)));
7124
7125
@@ -7137,8 +7138,8 @@ where
7137
7138
let block_hash = header.block_hash();
7138
7139
log_trace!(self.logger, "New best block: {} at height {}", block_hash, height);
7139
7140
7140
- let _persistence_guard = PersistenceNotifierGuard::optionally_notify(& self.total_consistency_lock ,
7141
- &self.event_persist_notifier, || -> NotifyOption { NotifyOption::DoPersist });
7141
+ let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self,
7142
+ || -> NotifyOption { NotifyOption::DoPersist });
7142
7143
*self.best_block.write().unwrap() = BestBlock::new(block_hash, height);
7143
7144
7144
7145
self.do_chain_event(Some(height), |channel| channel.best_block_updated(height, header.time, self.genesis_hash.clone(), &self.node_signer, &self.default_configuration, &self.logger));
@@ -7181,8 +7182,8 @@ where
7181
7182
}
7182
7183
7183
7184
fn transaction_unconfirmed(&self, txid: &Txid) {
7184
- let _persistence_guard = PersistenceNotifierGuard::optionally_notify(& self.total_consistency_lock ,
7185
- &self.event_persist_notifier, || -> NotifyOption { NotifyOption::DoPersist });
7185
+ let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self,
7186
+ || -> NotifyOption { NotifyOption::DoPersist });
7186
7187
self.do_chain_event(None, |channel| {
7187
7188
if let Some(funding_txo) = channel.context.get_funding_txo() {
7188
7189
if funding_txo.txid == *txid {
@@ -7520,7 +7521,7 @@ where
7520
7521
}
7521
7522
7522
7523
fn handle_channel_update(&self, counterparty_node_id: &PublicKey, msg: &msgs::ChannelUpdate) {
7523
- PersistenceNotifierGuard::optionally_notify(& self.total_consistency_lock, &self.event_persist_notifier , || {
7524
+ PersistenceNotifierGuard::optionally_notify(self, || {
7524
7525
let force_persist = self.process_background_events();
7525
7526
if let Ok(persist) = handle_error!(self, self.internal_channel_update(counterparty_node_id, msg), *counterparty_node_id) {
7526
7527
if force_persist == NotifyOption::DoPersist { NotifyOption::DoPersist } else { persist }
0 commit comments