Browse Source

don't delete floodfill if number of remaining floodfills is less than minimal

pull/1688/head
orignal 3 years ago
parent
commit
541464b705
  1. 9
      libi2pd/NetDb.cpp
  2. 1
      libi2pd/NetDb.hpp

9
libi2pd/NetDb.cpp

@ -577,8 +577,9 @@ namespace data @@ -577,8 +577,9 @@ namespace data
void NetDb::SaveUpdated ()
{
int updatedCount = 0, deletedCount = 0;
int updatedCount = 0, deletedCount = 0, deletedFloodfillsCount = 0;
auto total = m_RouterInfos.size ();
auto totalFloodfills = m_Floodfills.size ();
uint64_t expirationTimeout = NETDB_MAX_EXPIRATION_TIMEOUT*1000LL;
uint64_t ts = i2p::util::GetMillisecondsSinceEpoch();
auto uptime = i2p::context.GetUptime ();
@ -603,8 +604,9 @@ namespace data @@ -603,8 +604,9 @@ namespace data
updatedCount++;
continue;
}
// make router reachable back if too few routers
if (it.second->IsUnreachable () && total - deletedCount < NETDB_MIN_ROUTERS)
// make router reachable back if too few routers or floodfills
if (it.second->IsUnreachable () && (total - deletedCount < NETDB_MIN_ROUTERS ||
(it.second->IsFloodfill () && totalFloodfills - deletedFloodfillsCount < NETDB_MIN_FLOODFILLS)))
it.second->SetUnreachable (false);
// find & mark expired routers
if (!it.second->IsReachable () && it.second->IsSSU (false))
@ -618,6 +620,7 @@ namespace data @@ -618,6 +620,7 @@ namespace data
if (it.second->IsUnreachable ())
{
if (it.second->IsFloodfill ()) deletedFloodfillsCount++;
// delete RI file
m_Storage.Remove(ident);
deletedCount++;

1
libi2pd/NetDb.hpp

@ -36,6 +36,7 @@ namespace i2p @@ -36,6 +36,7 @@ namespace i2p
namespace data
{
const int NETDB_MIN_ROUTERS = 90;
const int NETDB_MIN_FLOODFILLS = 5;
const int NETDB_FLOODFILL_EXPIRATION_TIMEOUT = 60 * 60; // 1 hour, in seconds
const int NETDB_INTRODUCEE_EXPIRATION_TIMEOUT = 65 * 60;
const int NETDB_MIN_EXPIRATION_TIMEOUT = 90 * 60; // 1.5 hours

Loading…
Cancel
Save