add handover window to router contact updating

This commit is contained in:
Jeff Becker 2019-06-17 10:02:12 -04:00
parent 30f6a8ccd2
commit 389c414ee3
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
3 changed files with 4 additions and 1 deletions

View File

@ -1266,7 +1266,7 @@ namespace llarp
// remove stale routers // remove stale routers
nodedb()->VisitInsertedAfter( nodedb()->VisitInsertedAfter(
[&](const RouterContact &rc) { removeStale.insert(rc.pubkey); }, [&](const RouterContact &rc) { removeStale.insert(rc.pubkey); },
((RouterContact::UpdateInterval * 3) / 2) + now); (RouterContact::UpdateInterval + now + RouterContact::UpdateWindow));
nodedb()->RemoveIf([removeStale](const RouterContact &rc) -> bool { nodedb()->RemoveIf([removeStale](const RouterContact &rc) -> bool {
return removeStale.count(rc.pubkey) > 0; return removeStale.count(rc.pubkey) > 0;
}); });

View File

@ -33,6 +33,8 @@ namespace llarp
#endif #endif
/// every 30 minutes an RC is stale and needs updating /// every 30 minutes an RC is stale and needs updating
llarp_time_t RouterContact::UpdateInterval = 30 * 60 * 1000; llarp_time_t RouterContact::UpdateInterval = 30 * 60 * 1000;
// 1 minute window for update
llarp_time_t RouterContact::UpdateWindow = 60 * 1000;
NetID::NetID(const byte_t *val) : AlignedBuffer< 8 >() NetID::NetID(const byte_t *val) : AlignedBuffer< 8 >()
{ {

View File

@ -70,6 +70,7 @@ namespace llarp
static llarp_time_t Lifetime; static llarp_time_t Lifetime;
static llarp_time_t UpdateInterval; static llarp_time_t UpdateInterval;
static llarp_time_t UpdateWindow;
RouterContact() RouterContact()
{ {