@@ -6338,7 +6338,7 @@ where
63386338 /// Will regularly be called by the background processor.
63396339 pub fn process_pending_htlc_forwards(&self) {
63406340 let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
6341- let should_persist = NotifyOption::DoPersist ;
6341+ let mut should_persist = NotifyOption::SkipPersistNoEvents ;
63426342 self.process_pending_update_add_htlcs();
63436343
63446344 let mut new_events = VecDeque::new();
@@ -6349,6 +6349,7 @@ where
63496349 mem::swap(&mut forward_htlcs, &mut self.forward_htlcs.lock().unwrap());
63506350
63516351 for (short_chan_id, mut pending_forwards) in forward_htlcs {
6352+ should_persist = NotifyOption::DoPersist;
63526353 if short_chan_id != 0 {
63536354 let mut forwarding_counterparty = None;
63546355 macro_rules! forwarding_channel_not_found {
@@ -7135,7 +7136,7 @@ where
71357136 }
71367137
71377138 let best_block_height = self.best_block.read().unwrap().height;
7138- self.pending_outbound_payments.check_retry_payments(
7139+ let needs_persist = self.pending_outbound_payments.check_retry_payments(
71397140 &self.router,
71407141 || self.list_usable_channels(),
71417142 || self.compute_inflight_htlcs(),
@@ -7146,6 +7147,9 @@ where
71467147 &self.logger,
71477148 |args| self.send_payment_along_path(args),
71487149 );
7150+ if needs_persist {
7151+ should_persist = NotifyOption::DoPersist;
7152+ }
71497153
71507154 for (htlc_source, payment_hash, failure_reason, destination) in
71517155 failed_forwards.drain(..)
@@ -7163,11 +7167,14 @@ where
71637167 // next get a `get_and_clear_pending_msg_events` call, but some tests rely on it, and it's
71647168 // nice to do the work now if we can rather than while we're trying to get messages in the
71657169 // network stack.
7166- self.check_free_holding_cells();
7170+ if self.check_free_holding_cells() {
7171+ should_persist = NotifyOption::DoPersist;
7172+ }
71677173
71687174 if !new_events.is_empty() {
71697175 let mut events = self.pending_events.lock().unwrap();
71707176 events.append(&mut new_events);
7177+ should_persist = NotifyOption::DoPersist;
71717178 }
71727179 should_persist
71737180 });
0 commit comments