mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-22 00:59:08 +01:00
don't insert same floodfill twice
This commit is contained in:
parent
7d7bbf15bf
commit
336cd60920
1 changed files with 17 additions and 6 deletions
17
NetDb.cpp
17
NetDb.cpp
|
@ -188,25 +188,36 @@ namespace data
|
||||||
// TODO: check if floodfill has been changed
|
// TODO: check if floodfill has been changed
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
LogPrint (eLogDebug, "NetDb: RouterInfo is older: ", ident.ToBase64());
|
LogPrint (eLogDebug, "NetDb: RouterInfo is older: ", ident.ToBase64());
|
||||||
|
updated = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
r = std::make_shared<RouterInfo> (buf, len);
|
r = std::make_shared<RouterInfo> (buf, len);
|
||||||
if (!r->IsUnreachable ())
|
if (!r->IsUnreachable ())
|
||||||
{
|
{
|
||||||
LogPrint (eLogInfo, "NetDb: RouterInfo added: ", ident.ToBase64());
|
bool inserted = false;
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> l(m_RouterInfosMutex);
|
std::unique_lock<std::mutex> l(m_RouterInfosMutex);
|
||||||
m_RouterInfos[r->GetIdentHash ()] = r;
|
inserted = m_RouterInfos.insert ({r->GetIdentHash (), r}).second;
|
||||||
}
|
}
|
||||||
|
if (inserted)
|
||||||
|
{
|
||||||
|
LogPrint (eLogInfo, "NetDb: RouterInfo added: ", ident.ToBase64());
|
||||||
if (r->IsFloodfill () && r->IsReachable ()) // floodfill must be reachable
|
if (r->IsFloodfill () && r->IsReachable ()) // floodfill must be reachable
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> l(m_FloodfillsMutex);
|
std::unique_lock<std::mutex> l(m_FloodfillsMutex);
|
||||||
m_Floodfills.push_back (r);
|
m_Floodfills.push_back (r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogPrint (eLogWarning, "NetDb: Duplicated RouterInfo ", ident.ToBase64());
|
||||||
|
updated = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
updated = false;
|
updated = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue