mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-21 16:49:10 +01:00
clean-up from obsolete RouterInfos
This commit is contained in:
parent
2b87a58685
commit
6c6d013a76
1 changed files with 15 additions and 6 deletions
11
NetDb.cpp
11
NetDb.cpp
|
@ -207,6 +207,8 @@ namespace data
|
||||||
};
|
};
|
||||||
|
|
||||||
int count = 0, deletedCount = 0;
|
int count = 0, deletedCount = 0;
|
||||||
|
auto total = m_RouterInfos.size ();
|
||||||
|
uint64_t ts = i2p::util::GetMillisecondsSinceEpoch ();
|
||||||
for (auto it: m_RouterInfos)
|
for (auto it: m_RouterInfos)
|
||||||
{
|
{
|
||||||
if (it.second->IsUpdated ())
|
if (it.second->IsUpdated ())
|
||||||
|
@ -216,7 +218,13 @@ namespace data
|
||||||
it.second->SetUpdated (false);
|
it.second->SetUpdated (false);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
else if (it.second->IsUnreachable ())
|
else
|
||||||
|
{
|
||||||
|
// RouterInfo expires in 72 hours if more than 300
|
||||||
|
if (total > 300 && ts > it.second->GetTimestamp () + 3*24*3600*1000LL) // 3 days
|
||||||
|
it.second->SetUnreachable (true);
|
||||||
|
|
||||||
|
if (it.second->IsUnreachable ())
|
||||||
{
|
{
|
||||||
if (boost::filesystem::exists (GetFilePath (directory, it.second)))
|
if (boost::filesystem::exists (GetFilePath (directory, it.second)))
|
||||||
{
|
{
|
||||||
|
@ -225,6 +233,7 @@ namespace data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
LogPrint (count," new/updated routers saved");
|
LogPrint (count," new/updated routers saved");
|
||||||
if (deletedCount > 0)
|
if (deletedCount > 0)
|
||||||
|
|
Loading…
Add table
Reference in a new issue