Skip to content

Commit 3fada24

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 03f3422 commit 3fada24

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
@@ -6365,8 +6365,14 @@ where
63656365
///
63666366
/// Will regularly be called by the background processor.
63676367
pub fn process_pending_htlc_forwards(&self) {
6368-
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
6368+
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
6369+
self.internal_process_pending_htlc_forwards()
6370+
});
6371+
}
63696372

6373+
// Returns whether or not we need to re-persist.
6374+
fn internal_process_pending_htlc_forwards(&self) -> NotifyOption {
6375+
let should_persist = NotifyOption::DoPersist;
63706376
self.process_pending_update_add_htlcs();
63716377

63726378
let mut new_events = VecDeque::new();
@@ -6423,10 +6429,11 @@ where
64236429
self.check_free_holding_cells();
64246430

64256431
if new_events.is_empty() {
6426-
return;
6432+
return should_persist;
64276433
}
64286434
let mut events = self.pending_events.lock().unwrap();
64296435
events.append(&mut new_events);
6436+
should_persist
64306437
}
64316438

64326439
fn process_forward_htlcs(

0 commit comments

Comments
 (0)