Merge pull request #2617 from wpaulino/no-persist-same-channel-update
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Fri, 29 Sep 2023 17:39:49 +0000 (17:39 +0000)
committerGitHub <noreply@github.com>
Fri, 29 Sep 2023 17:39:49 +0000 (17:39 +0000)
Avoid persisting on same counterparty's ChannelUpdate

1  2 
lightning/src/ln/channelmanager.rs

index 00becff19d73c5e4a013ec2472addd4c2bdd8cc2,6b4f494efe2851186afb97bb10dd053505c6b40f..cfa17295a53f37bd8fabd63b54ea4053a27f27eb
@@@ -3471,8 -3471,9 +3471,8 @@@ wher
        /// In general, a path may raise:
        ///  * [`APIError::InvalidRoute`] when an invalid route or forwarding parameter (cltv_delta, fee,
        ///    node public key) is specified.
 -      ///  * [`APIError::ChannelUnavailable`] if the next-hop channel is not available for updates
 -      ///    (including due to previous monitor update failure or new permanent monitor update
 -      ///    failure).
 +      ///  * [`APIError::ChannelUnavailable`] if the next-hop channel is not available as it has been
 +      ///    closed, doesn't exist, or the peer is currently disconnected.
        ///  * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the
        ///    relevant updates.
        ///
                                                return Ok(NotifyOption::SkipPersistNoEvents);
                                        } else {
                                                log_debug!(self.logger, "Received channel_update {:?} for channel {}.", msg, chan_id);
-                                               try_chan_phase_entry!(self, chan.channel_update(&msg), chan_phase_entry);
+                                               let did_change = try_chan_phase_entry!(self, chan.channel_update(&msg), chan_phase_entry);
+                                               // If nothing changed after applying their update, we don't need to bother
+                                               // persisting.
+                                               if !did_change {
+                                                       return Ok(NotifyOption::SkipPersistNoEvents);
+                                               }
                                        }
                                } else {
                                        return try_chan_phase_entry!(self, Err(ChannelError::Close(