node: Always try to relay node announcements

They are cached and will often be old. They should still be relayed.
This commit is contained in:
cloudhead 2024-04-29 12:28:30 +02:00
parent 97b1a5de53
commit a815640a3b
No known key found for this signature in database
2 changed files with 11 additions and 4 deletions

View File

@ -1338,11 +1338,14 @@ where
let now = self.clock;
let timestamp = message.timestamp();
// To avoid spamming peers on startup with historical gossip messages,
// don't relay messages that are too old.
let relay = if now - timestamp.to_local_time() > MAX_TIME_DELTA {
false
} else {
// don't relay messages that are too old. We make an exception for node announcements,
// since they are cached, and will hence often carry old timestamps.
let relay = if message.is_node_announcement()
|| now - timestamp.to_local_time() <= MAX_TIME_DELTA
{
self.config.relay
} else {
false
};
// Don't allow messages from too far in the future.

View File

@ -274,6 +274,10 @@ impl AnnouncementMessage {
Self::Node(NodeAnnouncement { timestamp, .. }) => *timestamp,
}
}
pub fn is_node_announcement(&self) -> bool {
matches!(self, Self::Node(_))
}
}
impl From<NodeAnnouncement> for AnnouncementMessage {