Skip to content

Commit 3d5c33a

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 81cd02f commit 3d5c33a

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

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

63326338
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)