Skip to content

Commit d2b7bbe

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 03b6e0e commit d2b7bbe

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
@@ -6329,8 +6329,14 @@ where
63296329
/// Users implementing their own background processing logic should call this in irregular,
63306330
/// randomly-distributed intervals.
63316331
pub fn process_pending_htlc_forwards(&self) {
6332-
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
6332+
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
6333+
self.internal_process_pending_htlc_forwards()
6334+
});
6335+
}
63336336

6337+
// Returns whether or not we need to re-persist.
6338+
fn internal_process_pending_htlc_forwards(&self) -> NotifyOption {
6339+
let should_persist = NotifyOption::DoPersist;
63346340
self.process_pending_update_add_htlcs();
63356341

63366342
let mut new_events = VecDeque::new();
@@ -6386,10 +6392,11 @@ where
63866392
self.check_free_holding_cells();
63876393

63886394
if new_events.is_empty() {
6389-
return;
6395+
return should_persist;
63906396
}
63916397
let mut events = self.pending_events.lock().unwrap();
63926398
events.append(&mut new_events);
6399+
should_persist
63936400
}
63946401

63956402
fn process_forward_htlcs(

0 commit comments

Comments
 (0)