Skip to content

Commit

Permalink
f make logic more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Oct 16, 2024
1 parent b5efe05 commit 070d816
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10221,18 +10221,19 @@ where
// `channel_update`s for any channels less than a week old.
let funding_conf_height =
channel.context.get_funding_tx_confirmation_height().unwrap_or(height);
let mut should_announce = announcement_sigs.is_some() || funding_conf_height < height + 1008;
// To avoid broadcast storms after each block, only
// re-broadcast every hour (6 blocks) after the initial
// broadcast, or if this is the first time we're ready to
// broadcast this channel.
should_announce &= announcement_sigs.is_some() || funding_conf_height % 6 == height % 6;
let rebroadcast_announcement = funding_conf_height < height + 1008
&& funding_conf_height % 6 == height % 6;
let mut should_announce = announcement_sigs.is_some() || rebroadcast_announcement;
// Most of our tests were written when we only broadcasted
// `channel_announcement`s once and then never re-broadcasted
// them again, so disable the re-broadcasting entirely in tests
#[cfg(test)]
{
should_announce &= announcement_sigs.is_some();
should_announce = announcement_sigs.is_some();
}
if should_announce {
if let Some(announcement) = channel.get_signed_channel_announcement(
Expand Down

0 comments on commit 070d816

Please sign in to comment.