re enable rc expiration

pull/1961/head
Jeff 2 years ago
parent 769bc1e8df
commit 3337125110
No known key found for this signature in database
GPG Key ID: 025C02EE3A092F2D

@ -123,7 +123,7 @@ namespace llarp
if (fs::is_regular_file(f) and f.extension() == RC_FILE_EXT)
{
RouterContact rc{};
if (rc.Read(f) and rc.Verify(time_now_ms()))
if (rc.Read(f) and rc.Verify(time_now_ms(), false))
m_Entries.emplace(rc.pubkey, rc);
}
return true;

@ -940,6 +940,9 @@ namespace llarp
// purge this entry
if (not rc.IsPublicRouter())
return true;
/// clear out a fully expired RC
if (rc.IsExpired(now))
return true;
// clients have a notion of a whilelist
// we short circuit logic here so we dont remove
// routers that are not whitelisted for first hops

@ -25,17 +25,23 @@ namespace llarp
bool RouterContact::BlockBogons = true;
#ifdef TESTNET
// 1 minute for testnet
llarp_time_t RouterContact::Lifetime = 1min;
#else
/// 1 day for real network
llarp_time_t RouterContact::Lifetime = 24h;
#endif
/// 1 day rc lifespan
constexpr auto rc_lifetime = 24h;
/// an RC inserted long enough ago (4 hrs) is considered stale and is removed
llarp_time_t RouterContact::StaleInsertionAge = 4h;
constexpr auto rc_stale_age = 4h;
/// window of time in which a router wil try to update their RC before it is marked stale
constexpr auto rc_update_window = 5min;
/// update RCs shortly before they are about to expire
llarp_time_t RouterContact::UpdateInterval = RouterContact::StaleInsertionAge - 5min;
constexpr auto rc_update_interval = rc_stale_age - rc_update_window;
llarp_time_t RouterContact::Lifetime = rc_lifetime;
llarp_time_t RouterContact::StaleInsertionAge = rc_stale_age;
llarp_time_t RouterContact::UpdateInterval = rc_update_interval;
/// how many rc lifetime intervals should we wait until purging an rc
constexpr auto expiration_lifetime_generations = 10;
/// the max age of an rc before we want to expire it
constexpr auto rc_expire_age = rc_lifetime * expiration_lifetime_generations;
NetID::NetID(const byte_t* val)
{
@ -405,9 +411,7 @@ namespace llarp
bool
RouterContact::IsExpired(llarp_time_t now) const
{
(void)now;
return false;
// return Age(now) >= Lifetime;
return Age(now) >= rc_expire_age;
}
llarp_time_t

Loading…
Cancel
Save