@@ -6336,7 +6336,7 @@ where
63366336
63376337 // Returns whether or not we need to re-persist.
63386338 fn internal_process_pending_htlc_forwards(&self) -> NotifyOption {
6339- let should_persist = NotifyOption::DoPersist ;
6339+ let mut should_persist = NotifyOption::SkipPersistNoEvents ;
63406340 self.process_pending_update_add_htlcs();
63416341
63426342 let mut new_events = VecDeque::new();
@@ -6346,6 +6346,7 @@ where
63466346 mem::swap(&mut forward_htlcs, &mut self.forward_htlcs.lock().unwrap());
63476347
63486348 for (short_chan_id, mut pending_forwards) in forward_htlcs {
6349+ should_persist = NotifyOption::DoPersist;
63496350 if short_chan_id != 0 {
63506351 self.process_forward_htlcs(
63516352 short_chan_id,
@@ -6363,7 +6364,7 @@ where
63636364 }
63646365
63656366 let best_block_height = self.best_block.read().unwrap().height;
6366- self.pending_outbound_payments.check_retry_payments(
6367+ let needs_persist = self.pending_outbound_payments.check_retry_payments(
63676368 &self.router,
63686369 || self.list_usable_channels(),
63696370 || self.compute_inflight_htlcs(),
@@ -6374,6 +6375,9 @@ where
63746375 &self.logger,
63756376 |args| self.send_payment_along_path(args),
63766377 );
6378+ if needs_persist {
6379+ should_persist = NotifyOption::DoPersist;
6380+ }
63776381
63786382 for (htlc_source, payment_hash, failure_reason, destination) in failed_forwards.drain(..) {
63796383 self.fail_htlc_backwards_internal(
@@ -6389,13 +6393,17 @@ where
63896393 // next get a `get_and_clear_pending_msg_events` call, but some tests rely on it, and it's
63906394 // nice to do the work now if we can rather than while we're trying to get messages in the
63916395 // network stack.
6392- self.check_free_holding_cells();
6396+ if self.check_free_holding_cells() {
6397+ should_persist = NotifyOption::DoPersist;
6398+ }
63936399
63946400 if new_events.is_empty() {
63956401 return should_persist;
63966402 }
63976403 let mut events = self.pending_events.lock().unwrap();
63986404 events.append(&mut new_events);
6405+ should_persist = NotifyOption::DoPersist;
6406+
63996407 should_persist
64006408 }
64016409
0 commit comments