Skip to content

Commit

Permalink
check actual distance with router to reduce expiration time
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Oct 31, 2023
1 parent a6ee1e6 commit a3f62e1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions libi2pd/NetDb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,12 +661,13 @@ namespace data
}
else if (checkForExpiration)
{
uint64_t t = expirationTimeout;
if (total > NETDB_NUM_ROUTERS_THRESHOLD && !it.second->IsHighBandwidth () && // low bandwidth router
((it.second->GetIdentHash()[0] & 0xFE) != (i2p::context.GetIdentHash ()[0] & 0xFE))) // different first 7 bits
t >>= 1; // reduce expiration time by 2 times
if (ts > it.second->GetTimestamp () + t)
if (ts > it.second->GetTimestamp () + expirationTimeout)
it.second->SetUnreachable (true);
else if ((ts > it.second->GetTimestamp () + expirationTimeout/2) && // more than half of expiration
total > NETDB_NUM_ROUTERS_THRESHOLD && !it.second->IsHighBandwidth() && // low bandwidth
!it.second->IsFloodfill() && (!i2p::context.IsFloodfill () || // non floodfill
(CreateRoutingKey (it.second->GetIdentHash ()) ^ i2p::context.GetIdentHash ()).metric[0] >= 0x02)) // different first 7 bits
it.second->SetUnreachable (true);
}
if (it.second->IsUnreachable () && i2p::transport::transports.IsConnected (it.second->GetIdentHash ()))
it.second->SetUnreachable (false); // don't expire connected router
Expand Down

0 comments on commit a3f62e1

Please sign in to comment.