Skip to content

Commit 2286a76

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 b676d14 commit 2286a76

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

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

63336339
let mut new_events = VecDeque::new();
@@ -6383,10 +6389,11 @@ where
63836389
self.check_free_holding_cells();
63846390

63856391
if new_events.is_empty() {
6386-
return;
6392+
return should_persist;
63876393
}
63886394
let mut events = self.pending_events.lock().unwrap();
63896395
events.append(&mut new_events);
6396+
should_persist
63906397
}
63916398

63926399
fn process_forward_htlcs(

0 commit comments

Comments
 (0)