gossipd: move timestamp_reasonable into gossmap_manage.c.

It's only used in there anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2025-12-09 13:02:25 +10:30
committed by Christian Decker
parent 4c8d656f77
commit d6f6d46c3b
3 changed files with 15 additions and 20 deletions

View File

@@ -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)
{

View File

@@ -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 */

View File

@@ -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,