Skip to content

Commit db8496c

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.
1 parent a100077 commit db8496c

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
@@ -6334,8 +6334,14 @@ where
63346334
/// Users implementing their own background processing logic should call this in irregular,
63356335
/// randomly-distributed intervals.
63366336
pub fn process_pending_htlc_forwards(&self) {
6337-
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
6337+
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
6338+
self.internal_process_pending_htlc_forwards()
6339+
});
6340+
}
63386341

6342+
// Returns whether or not we need to re-persist.
6343+
fn internal_process_pending_htlc_forwards(&self) -> NotifyOption {
6344+
let should_persist = NotifyOption::DoPersist;
63396345
self.process_pending_update_add_htlcs();
63406346

63416347
let mut new_events = VecDeque::new();
@@ -6391,10 +6397,11 @@ where
63916397
self.check_free_holding_cells();
63926398

63936399
if new_events.is_empty() {
6394-
return;
6400+
return should_persist;
63956401
}
63966402
let mut events = self.pending_events.lock().unwrap();
63976403
events.append(&mut new_events);
6404+
should_persist
63986405
}
63996406

64006407
fn process_forward_htlcs(

0 commit comments

Comments
 (0)