Skip to content

Commit 9949a33

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 5e7bb65 commit 9949a33

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
@@ -6356,8 +6356,14 @@ where
63566356
///
63576357
/// Will regularly be called by the background processor.
63586358
pub fn process_pending_htlc_forwards(&self) {
6359-
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
6359+
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
6360+
self.internal_process_pending_htlc_forwards()
6361+
});
6362+
}
63606363

6364+
// Returns whether or not we need to re-persist.
6365+
fn internal_process_pending_htlc_forwards(&self) -> NotifyOption {
6366+
let should_persist = NotifyOption::DoPersist;
63616367
self.process_pending_update_add_htlcs();
63626368

63636369
let mut new_events = VecDeque::new();
@@ -6414,10 +6420,11 @@ where
64146420
self.check_free_holding_cells();
64156421

64166422
if new_events.is_empty() {
6417-
return;
6423+
return should_persist;
64186424
}
64196425
let mut events = self.pending_events.lock().unwrap();
64206426
events.append(&mut new_events);
6427+
should_persist
64216428
}
64226429

64236430
fn process_forward_htlcs(

0 commit comments

Comments
 (0)