|
|
@ -118,7 +118,6 @@ namespace data |
|
|
|
{ |
|
|
|
{ |
|
|
|
SaveUpdated (); |
|
|
|
SaveUpdated (); |
|
|
|
ManageLeaseSets (); |
|
|
|
ManageLeaseSets (); |
|
|
|
ManageLookupResponses (); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
lastSave = ts; |
|
|
|
lastSave = ts; |
|
|
|
} |
|
|
|
} |
|
|
@ -857,21 +856,6 @@ namespace data |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!replyMsg) |
|
|
|
if (!replyMsg) |
|
|
|
{ |
|
|
|
|
|
|
|
LogPrint (eLogWarning, "NetDb: Requested ", key, " not found, ", numExcluded, " peers excluded"); |
|
|
|
|
|
|
|
// find or cleate response
|
|
|
|
|
|
|
|
std::vector<IdentHash> closestFloodfills; |
|
|
|
|
|
|
|
bool found = false; |
|
|
|
|
|
|
|
if (!numExcluded) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
auto it = m_LookupResponses.find (ident); |
|
|
|
|
|
|
|
if (it != m_LookupResponses.end ()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
closestFloodfills = it->second.first; |
|
|
|
|
|
|
|
found = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!found) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
std::set<IdentHash> excludedRouters; |
|
|
|
std::set<IdentHash> excludedRouters; |
|
|
|
const uint8_t * exclude_ident = excluded; |
|
|
|
const uint8_t * exclude_ident = excluded; |
|
|
@ -880,10 +864,9 @@ namespace data |
|
|
|
excludedRouters.insert (exclude_ident); |
|
|
|
excludedRouters.insert (exclude_ident); |
|
|
|
exclude_ident += 32; |
|
|
|
exclude_ident += 32; |
|
|
|
} |
|
|
|
} |
|
|
|
closestFloodfills = GetClosestFloodfills (ident, 3, excludedRouters, true); |
|
|
|
auto closestFloodfills = GetClosestFloodfills (ident, 3, excludedRouters, true); |
|
|
|
if (!numExcluded) // save if no excluded
|
|
|
|
if (closestFloodfills.empty ()) |
|
|
|
m_LookupResponses[ident] = std::make_pair(closestFloodfills, i2p::util::GetSecondsSinceEpoch ()); |
|
|
|
LogPrint (eLogWarning, "NetDb: Requested ", key, " not found, ", numExcluded, " peers excluded"); |
|
|
|
} |
|
|
|
|
|
|
|
replyMsg = CreateDatabaseSearchReply (ident, closestFloodfills); |
|
|
|
replyMsg = CreateDatabaseSearchReply (ident, closestFloodfills); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1191,17 +1174,5 @@ namespace data |
|
|
|
++it; |
|
|
|
++it; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NetDb::ManageLookupResponses () |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
auto ts = i2p::util::GetSecondsSinceEpoch (); |
|
|
|
|
|
|
|
for (auto it = m_LookupResponses.begin (); it != m_LookupResponses.end ();) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (ts > it->second.second + 180) // 3 minutes
|
|
|
|
|
|
|
|
it = m_LookupResponses.erase (it); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
++it; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|