]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Drop pending outbound messages on peer disconnection
authorMatt Corallo <git@bluematt.me>
Tue, 8 Jan 2019 04:11:37 +0000 (23:11 -0500)
committerMatt Corallo <git@bluematt.me>
Thu, 24 Jan 2019 18:16:59 +0000 (13:16 -0500)
This shouldn't be required, but it may help prevent some downstream
race conditions due to clients not sending message events quickly
enough and trying to send stale messages before new
channel_reestablish messages.

src/ln/channelmanager.rs

index 927feca2a5fa84f70663244b1e5300b4b6930d11..ae5842463b9c843531d4aca089eaf334d3459e61 100644 (file)
@@ -2616,6 +2616,25 @@ impl ChannelMessageHandler for ChannelManager {
                                        true
                                })
                        }
+                       pending_msg_events.retain(|msg| {
+                               match msg {
+                                       &events::MessageSendEvent::SendAcceptChannel { ref node_id, .. } => node_id != their_node_id,
+                                       &events::MessageSendEvent::SendOpenChannel { ref node_id, .. } => node_id != their_node_id,
+                                       &events::MessageSendEvent::SendFundingCreated { ref node_id, .. } => node_id != their_node_id,
+                                       &events::MessageSendEvent::SendFundingSigned { ref node_id, .. } => node_id != their_node_id,
+                                       &events::MessageSendEvent::SendFundingLocked { ref node_id, .. } => node_id != their_node_id,
+                                       &events::MessageSendEvent::SendAnnouncementSignatures { ref node_id, .. } => node_id != their_node_id,
+                                       &events::MessageSendEvent::UpdateHTLCs { ref node_id, .. } => node_id != their_node_id,
+                                       &events::MessageSendEvent::SendRevokeAndACK { ref node_id, .. } => node_id != their_node_id,
+                                       &events::MessageSendEvent::SendClosingSigned { ref node_id, .. } => node_id != their_node_id,
+                                       &events::MessageSendEvent::SendShutdown { ref node_id, .. } => node_id != their_node_id,
+                                       &events::MessageSendEvent::SendChannelReestablish { ref node_id, .. } => node_id != their_node_id,
+                                       &events::MessageSendEvent::BroadcastChannelAnnouncement { .. } => true,
+                                       &events::MessageSendEvent::BroadcastChannelUpdate { .. } => true,
+                                       &events::MessageSendEvent::HandleError { ref node_id, .. } => node_id != their_node_id,
+                                       &events::MessageSendEvent::PaymentFailureNetworkUpdate { .. } => true,
+                               }
+                       });
                }
                for failure in failed_channels.drain(..) {
                        self.finish_force_close_channel(failure);