]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Separate ChannelAnnouncement and ChannelUpdate broadcast conditions
authorMatt Corallo <git@bluematt.me>
Sat, 13 Nov 2021 00:27:05 +0000 (00:27 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 23 Nov 2021 22:17:18 +0000 (22:17 +0000)
When a `ChannelUpdate` message is generated for broadcast as a part
of a `BroadcastChannelAnnouncement` event, it may be newer than our
previous `ChannelUpdate` and need to be broadcast. However, if the
`ChannelAnnouncement` had already been seen we wouldn't
re-broadcast either message as the `handle_channel_announcement`
call would fail, short-circuiting the condition to broadcast both.

Instead, we split the broadcast of each message as well as the
conditional so that we always attempt to handle each message and
update our local graph state, then broadcast the message if its
update was processed successfully.

lightning/src/ln/peer_handler.rs

index 89f3e9ff5ffa48233086af330cb0fdb6ccf58f15..a30e498a62ebff7d15d2f44a516e3ba6a8517855 100644 (file)
@@ -1351,8 +1351,10 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref, CMH: Deref> P
                                        },
                                        MessageSendEvent::BroadcastChannelAnnouncement { msg, update_msg } => {
                                                log_debug!(self.logger, "Handling BroadcastChannelAnnouncement event in peer_handler for short channel id {}", msg.contents.short_channel_id);
-                                               if self.message_handler.route_handler.handle_channel_announcement(&msg).is_ok() && self.message_handler.route_handler.handle_channel_update(&update_msg).is_ok() {
+                                               if self.message_handler.route_handler.handle_channel_announcement(&msg).is_ok() {
                                                        self.forward_broadcast_msg(peers, &wire::Message::ChannelAnnouncement(msg), None);
+                                               }
+                                               if self.message_handler.route_handler.handle_channel_update(&update_msg).is_ok() {
                                                        self.forward_broadcast_msg(peers, &wire::Message::ChannelUpdate(update_msg), None);
                                                }
                                        },