gossipd: move timestamp_reasonable into gossmap_manage.c.
What changed, and why it matters
This commit is a simple internal code cleanup: a helper function that checks whether a gossip timestamp is reasonable is moved from a shared header file into the only file that actually uses it, and its visibility is changed from public to private (static). There is no change to what the function does, no bug fix, and no security-relevant behavior change.
No security action needed. Treat as routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The timestamp_reasonable() function is relocated from gossipd.c/gossipd.h to gossmap_manage.c and marked static. The implementation, logic, and comments remain identical. This is a pure refactoring change that reduces unnecessary global scope.
Changed components
gossipd/gossipd.cgossipd/gossipd.hgossipd/gossmap_manage.cInspect captured patch +15 / −20
diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c
index e6730d18..f82833b6 100644
--- a/gossipd/gossipd.c
+++ b/gossipd/gossipd.c
@@ -368,21 +368,6 @@ static void master_or_connectd_gone(struct daemon_conn *dc UNUSED)
exit(2);
}
-/* We don't check this when loading from the gossip_store: that would break
- * our canned tests, and usually old gossip is better than no gossip */
-bool timestamp_reasonable(const struct daemon *daemon, u32 timestamp)
-{
- u64 now = clock_time().ts.tv_sec;
-
- /* More than one day ahead? */
- if (timestamp > now + 24*60*60)
- return false;
- /* More than 2 weeks behind? */
- if (timestamp < now - GOSSIP_PRUNE_INTERVAL(daemon->dev_fast_gossip_prune))
- return false;
- return true;
-}
-
/*~ Parse init message from lightningd: starts the daemon properly. */
static void gossip_init(struct daemon *daemon, const u8 *msg)
{
diff --git a/gossipd/gossipd.h b/gossipd/gossipd.h
index 93d79373..d8aa5447 100644
--- a/gossipd/gossipd.h
+++ b/gossipd/gossipd.h
@@ -158,9 +158,4 @@ void tell_lightningd_peer_update(struct daemon *daemon,
struct amount_msat htlc_minimum,
struct amount_msat htlc_maximum);
-/**
- * Is this gossip timestamp reasonable?
- */
-bool timestamp_reasonable(const struct daemon *daemon, u32 timestamp);
-
#endif /* LIGHTNING_GOSSIPD_GOSSIPD_H */
diff --git a/gossipd/gossmap_manage.c b/gossipd/gossmap_manage.c
index fb9a1d85..7a371d0f 100644
--- a/gossipd/gossmap_manage.c
+++ b/gossipd/gossmap_manage.c
@@ -893,6 +893,21 @@ static const char *process_channel_update(const tal_t *ctx,
return NULL;
}
+/* We don't check this when loading from the gossip_store: that would break
+ * our canned tests, and usually old gossip is better than no gossip */
+static bool timestamp_reasonable(const struct daemon *daemon, u32 timestamp)
+{
+ u64 now = clock_time().ts.tv_sec;
+
+ /* More than one day ahead? */
+ if (timestamp > now + 24*60*60)
+ return false;
+ /* More than 2 weeks behind? */
+ if (timestamp < now - GOSSIP_PRUNE_INTERVAL(daemon->dev_fast_gossip_prune))
+ return false;
+ return true;
+}
+
const char *gossmap_manage_channel_update(const tal_t *ctx,
struct gossmap_manage *gm,
const u8 *update TAKES,
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.