|
|
|
@ -148,7 +148,7 @@ namespace data
@@ -148,7 +148,7 @@ namespace data
|
|
|
|
|
{ |
|
|
|
|
auto numRouters = m_RouterInfos.size (); |
|
|
|
|
if (!numRouters) |
|
|
|
|
throw std::runtime_error("No known routers, reseed seems to be totally failed"); |
|
|
|
|
throw std::runtime_error("No known routers, reseed seems to be totally failed"); |
|
|
|
|
else // we have peers now
|
|
|
|
|
m_FloodfillBootstrap = nullptr; |
|
|
|
|
if (numRouters < 2500 || ts - lastExploratory >= 90) |
|
|
|
@ -172,9 +172,9 @@ namespace data
@@ -172,9 +172,9 @@ namespace data
|
|
|
|
|
|
|
|
|
|
void NetDb::SetHidden(bool hide) |
|
|
|
|
{ |
|
|
|
|
// TODO: remove reachable addresses from router info
|
|
|
|
|
m_HiddenMode = hide; |
|
|
|
|
} |
|
|
|
|
// TODO: remove reachable addresses from router info
|
|
|
|
|
m_HiddenMode = hide; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool NetDb::AddRouterInfo (const uint8_t * buf, int len) |
|
|
|
|
{ |
|
|
|
@ -319,6 +319,9 @@ namespace data
@@ -319,6 +319,9 @@ namespace data
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<RouterProfile> NetDb::FindRouterProfile (const IdentHash& ident) const |
|
|
|
|
{ |
|
|
|
|
if (!m_PersistProfiles) |
|
|
|
|
return nullptr; |
|
|
|
|
|
|
|
|
|
auto router = FindRouter (ident); |
|
|
|
|
return router ? router->GetProfile () : nullptr; |
|
|
|
|
} |
|
|
|
@ -418,8 +421,9 @@ namespace data
@@ -418,8 +421,9 @@ namespace data
|
|
|
|
|
|
|
|
|
|
void NetDb::VisitStoredRouterInfos(RouterInfoVisitor v) |
|
|
|
|
{ |
|
|
|
|
m_Storage.Iterate([v] (const std::string & filename) { |
|
|
|
|
auto ri = std::make_shared<i2p::data::RouterInfo>(filename); |
|
|
|
|
m_Storage.Iterate([v] (const std::string & filename) |
|
|
|
|
{ |
|
|
|
|
auto ri = std::make_shared<i2p::data::RouterInfo>(filename); |
|
|
|
|
v(ri); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -555,7 +559,7 @@ namespace data
@@ -555,7 +559,7 @@ namespace data
|
|
|
|
|
++it; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// clean up expired floodfiils
|
|
|
|
|
// clean up expired floodfills
|
|
|
|
|
{ |
|
|
|
|
std::unique_lock<std::mutex> l(m_FloodfillsMutex); |
|
|
|
|
for (auto it = m_Floodfills.begin (); it != m_Floodfills.end ();) |
|
|
|
@ -873,7 +877,7 @@ namespace data
@@ -873,7 +877,7 @@ namespace data
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!replyMsg && (lookupType == DATABASE_LOOKUP_TYPE_LEASESET_LOOKUP || |
|
|
|
|
lookupType == DATABASE_LOOKUP_TYPE_NORMAL_LOOKUP)) |
|
|
|
|
lookupType == DATABASE_LOOKUP_TYPE_NORMAL_LOOKUP)) |
|
|
|
|
{ |
|
|
|
|
auto leaseSet = FindLeaseSet (ident); |
|
|
|
|
if (!leaseSet) |
|
|
|
@ -1180,13 +1184,13 @@ namespace data
@@ -1180,13 +1184,13 @@ namespace data
|
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::shared_ptr<const RouterInfo> NetDb::GetRandomRouterInFamily(const std::string & fam) const { |
|
|
|
|
return GetRandomRouter( |
|
|
|
|
[fam](std::shared_ptr<const RouterInfo> router)->bool |
|
|
|
|
{ |
|
|
|
|
return router->IsFamily(fam); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
std::shared_ptr<const RouterInfo> NetDb::GetRandomRouterInFamily(const std::string & fam) const { |
|
|
|
|
return GetRandomRouter( |
|
|
|
|
[fam](std::shared_ptr<const RouterInfo> router)->bool |
|
|
|
|
{ |
|
|
|
|
return router->IsFamily(fam); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::shared_ptr<const RouterInfo> NetDb::GetClosestNonFloodfill (const IdentHash& destination, |
|
|
|
|
const std::set<IdentHash>& excluded) const |
|
|
|
|