From 99aeae19ea105660746db99814bc1f8ceb7133bd Mon Sep 17 00:00:00 2001 From: cloudhead Date: Wed, 13 Dec 2023 14:37:04 +0100 Subject: [PATCH] node: Fix node announcements not being received Since node announcements are stored and retrieved from disk (due to the PoW), the timestamp on it is never updated. This means it can be too old to cache and not sent/received by nodes. Fix this by having a max age. --- radicle-node/src/runtime.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/radicle-node/src/runtime.rs b/radicle-node/src/runtime.rs index cf0a5c2f..c002bb2c 100644 --- a/radicle-node/src/runtime.rs +++ b/radicle-node/src/runtime.rs @@ -155,6 +155,18 @@ impl Runtime { let announcement = if let Some(ann) = fs::read(node_dir.join(node::NODE_ANNOUNCEMENT_FILE)) .ok() .and_then(|ann| NodeAnnouncement::decode(&mut ann.as_slice()).ok()) + .and_then(|ann| { + // If our announcement was made some time ago, the timestamp on it will be old, + // and it might not get gossiped to new nodes since it will be purged from caches. + // Therefore, we make sure it's never too old. + if clock.as_millis() - ann.timestamp + <= config.limits.gossip_max_age.as_millis() as u64 + { + Some(ann) + } else { + None + } + }) .and_then(|ann| { if config.features() == ann.features && config.alias == ann.alias