Skip to content

Commit 0236418

Browse files
committed
Use optionally_notify in process_pending_htlc_forwards
We move the code into the `optionally_notify` closure, but maintain the behavior for now. In the next step, we'll use this to make sure we only repersist when necessary. Best reviewed via `git diff --ignore-all-space`
1 parent 4740d01 commit 0236418

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6334,8 +6334,14 @@ where
63346334
///
63356335
/// Will regularly be called by the background processor.
63366336
pub fn process_pending_htlc_forwards(&self) {
6337-
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
6337+
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
6338+
self.internal_process_pending_htlc_forwards()
6339+
});
6340+
}
63386341

6342+
// Returns whether or not we need to re-persist.
6343+
fn internal_process_pending_htlc_forwards(&self) -> NotifyOption {
6344+
let should_persist = NotifyOption::DoPersist;
63396345
self.process_pending_update_add_htlcs();
63406346

63416347
let mut new_events = VecDeque::new();
@@ -7135,10 +7141,11 @@ where
71357141
self.check_free_holding_cells();
71367142

71377143
if new_events.is_empty() {
7138-
return;
7144+
return should_persist;
71397145
}
71407146
let mut events = self.pending_events.lock().unwrap();
71417147
events.append(&mut new_events);
7148+
should_persist
71427149
}
71437150

71447151
/// Free the background events, generally called from [`PersistenceNotifierGuard`] constructors.

0 commit comments

Comments
 (0)