@@ -10371,23 +10371,48 @@ where
1037110371									emit_channel_ready_event!(pending_events, channel);
1037210372								}
1037310373
10374- 								if let Some(announcement_sigs) = announcement_sigs {
10375- 									log_trace!(logger, "Sending announcement_signatures for channel {}", channel.context.channel_id());
10376- 									pending_msg_events.push(events::MessageSendEvent::SendAnnouncementSignatures {
10377- 										node_id: channel.context.get_counterparty_node_id(),
10378- 										msg: announcement_sigs,
10379- 									});
10380- 									if let Some(height) = height_opt {
10381- 										if let Some(announcement) = channel.get_signed_channel_announcement(&self.node_signer, self.chain_hash, height, &self.default_configuration) {
10374+ 								if let Some(height) = height_opt {
10375+ 									// (re-)broadcast signed `channel_announcement`s and
10376+ 									// `channel_update`s for any channels less than a week old.
10377+ 									let funding_conf_height =
10378+ 										channel.context.get_funding_tx_confirmation_height().unwrap_or(height);
10379+ 									// To avoid broadcast storms after each block, only
10380+ 									// re-broadcast every hour (6 blocks) after the initial
10381+ 									// broadcast, or if this is the first time we're ready to
10382+ 									// broadcast this channel.
10383+ 									let rebroadcast_announcement = funding_conf_height < height + 1008
10384+ 										&& funding_conf_height % 6 == height % 6;
10385+ 									#[allow(unused_mut, unused_assignments)]
10386+ 									let mut should_announce = announcement_sigs.is_some() || rebroadcast_announcement;
10387+ 									// Most of our tests were written when we only broadcasted
10388+ 									// `channel_announcement`s once and then never re-broadcasted
10389+ 									// them again, so disable the re-broadcasting entirely in tests
10390+ 									#[cfg(test)]
10391+ 									{
10392+ 										should_announce = announcement_sigs.is_some();
10393+ 									}
10394+ 									if should_announce {
10395+ 										if let Some(announcement) = channel.get_signed_channel_announcement(
10396+ 											&self.node_signer, self.chain_hash, height, &self.default_configuration,
10397+ 										) {
1038210398											pending_msg_events.push(events::MessageSendEvent::BroadcastChannelAnnouncement {
1038310399												msg: announcement,
10384- 												// Note that announcement_signatures fails if the channel cannot be announced,
10385- 												// so get_channel_update_for_broadcast will never fail by the time we get here.
10400+ 												// Note that get_signed_channel_announcement fails
10401+ 												// if the channel cannot be announced, so
10402+ 												// get_channel_update_for_broadcast will never fail
10403+ 												// by the time we get here.
1038610404												update_msg: Some(self.get_channel_update_for_broadcast(channel).unwrap()),
1038710405											});
1038810406										}
1038910407									}
1039010408								}
10409+ 								if let Some(announcement_sigs) = announcement_sigs {
10410+ 									log_trace!(logger, "Sending announcement_signatures for channel {}", channel.context.channel_id());
10411+ 									pending_msg_events.push(events::MessageSendEvent::SendAnnouncementSignatures {
10412+ 										node_id: channel.context.get_counterparty_node_id(),
10413+ 										msg: announcement_sigs,
10414+ 									});
10415+ 								}
1039110416								if channel.is_our_channel_ready() {
1039210417									if let Some(real_scid) = channel.context.get_short_channel_id() {
1039310418										// If we sent a 0conf channel_ready, and now have an SCID, we add it
0 commit comments