Browse Source

ignore non-reachable floodfills

pull/388/head
orignal 9 years ago
parent
commit
ca6f656e1b
  1. 9
      NetDb.cpp
  2. 5
      RouterInfo.cpp
  3. 3
      RouterInfo.h

9
NetDb.cpp

@ -170,6 +170,7 @@ namespace data
{ {
r->Update (buf, len); r->Update (buf, len);
LogPrint (eLogInfo, "NetDb: RouterInfo updated: ", ident.ToBase64()); LogPrint (eLogInfo, "NetDb: RouterInfo updated: ", ident.ToBase64());
// TODO: check if floodfill has been changed
} }
else else
{ {
@ -187,7 +188,7 @@ namespace data
std::unique_lock<std::mutex> l(m_RouterInfosMutex); std::unique_lock<std::mutex> l(m_RouterInfosMutex);
m_RouterInfos[r->GetIdentHash ()] = r; m_RouterInfos[r->GetIdentHash ()] = r;
} }
if (r->IsFloodfill ()) 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);
@ -298,9 +299,11 @@ namespace data
r->DeleteBuffer (); r->DeleteBuffer ();
r->ClearProperties (); // properties are not used for regular routers r->ClearProperties (); // properties are not used for regular routers
m_RouterInfos[r->GetIdentHash ()] = r; m_RouterInfos[r->GetIdentHash ()] = r;
if (r->IsFloodfill ()) if (r->IsFloodfill () && r->IsReachable ()) // floodfill must be reachable
m_Floodfills.push_back (r); m_Floodfills.push_back (r);
} else { }
else
{
LogPrint(eLogWarning, "NetDb: Can't load RI from ", path, ", delete"); LogPrint(eLogWarning, "NetDb: Can't load RI from ", path, ", delete");
i2p::fs::Remove(path); i2p::fs::Remove(path);
} }

5
RouterInfo.cpp

@ -629,11 +629,6 @@ namespace data
m_Properties.erase (key); m_Properties.erase (key);
} }
bool RouterInfo::IsFloodfill () const
{
return m_Caps & Caps::eFloodfill;
}
bool RouterInfo::IsNTCP (bool v4only) const bool RouterInfo::IsNTCP (bool v4only) const
{ {
if (v4only) if (v4only)

3
RouterInfo.h

@ -128,7 +128,8 @@ namespace data
void SetProperty (const std::string& key, const std::string& value); // called from RouterContext only void SetProperty (const std::string& key, const std::string& value); // called from RouterContext only
void DeleteProperty (const std::string& key); // called from RouterContext only void DeleteProperty (const std::string& key); // called from RouterContext only
void ClearProperties () { m_Properties.clear (); }; void ClearProperties () { m_Properties.clear (); };
bool IsFloodfill () const; bool IsFloodfill () const { return m_Caps & Caps::eFloodfill; };
bool IsReachable () const { return m_Caps & Caps::eReachable; };
bool IsNTCP (bool v4only = true) const; bool IsNTCP (bool v4only = true) const;
bool IsSSU (bool v4only = true) const; bool IsSSU (bool v4only = true) const;
bool IsV6 () const; bool IsV6 () const;

Loading…
Cancel
Save