Skip to content

Commit ef3ffb5

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 8c88c8d commit ef3ffb5

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
@@ -6324,8 +6324,14 @@ where
63246324
///
63256325
/// Will regularly be called by the background processor.
63266326
pub fn process_pending_htlc_forwards(&self) {
6327-
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
6327+
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
6328+
self.internal_process_pending_htlc_forwards()
6329+
});
6330+
}
63286331

6332+
// Returns whether or not we need to re-persist.
6333+
fn internal_process_pending_htlc_forwards(&self) -> NotifyOption {
6334+
let should_persist = NotifyOption::DoPersist;
63296335
self.process_pending_update_add_htlcs();
63306336

63316337
let mut new_events = VecDeque::new();
@@ -6382,10 +6388,11 @@ where
63826388
self.check_free_holding_cells();
63836389

63846390
if new_events.is_empty() {
6385-
return;
6391+
return should_persist;
63866392
}
63876393
let mut events = self.pending_events.lock().unwrap();
63886394
events.append(&mut new_events);
6395+
should_persist
63896396
}
63906397

63916398
fn process_forward_htlcs(

0 commit comments

Comments
 (0)