From: Matt Corallo Date: Sat, 13 Nov 2021 00:27:05 +0000 (+0000) Subject: Separate ChannelAnnouncement and ChannelUpdate broadcast conditions X-Git-Tag: v0.0.104~8^2~4 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=74828d243567af448cec5f09eb2d6a8eeed3ca48;p=rust-lightning Separate ChannelAnnouncement and ChannelUpdate broadcast conditions 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. --- diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index 89f3e9ff5..a30e498a6 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -1351,8 +1351,10 @@ impl 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); } },