mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-25 23:44:18 +00:00
don't store lookup replies anymore
This commit is contained in:
parent
adf887a06b
commit
59681398cb
53
NetDb.cpp
53
NetDb.cpp
@ -118,7 +118,6 @@ namespace data
|
|||||||
{
|
{
|
||||||
SaveUpdated ();
|
SaveUpdated ();
|
||||||
ManageLeaseSets ();
|
ManageLeaseSets ();
|
||||||
ManageLookupResponses ();
|
|
||||||
}
|
}
|
||||||
lastSave = ts;
|
lastSave = ts;
|
||||||
}
|
}
|
||||||
@ -857,37 +856,17 @@ namespace data
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!replyMsg)
|
if (!replyMsg)
|
||||||
{
|
{
|
||||||
LogPrint (eLogWarning, "NetDb: Requested ", key, " not found, ", numExcluded, " peers excluded");
|
std::set<IdentHash> excludedRouters;
|
||||||
// find or cleate response
|
const uint8_t * exclude_ident = excluded;
|
||||||
std::vector<IdentHash> closestFloodfills;
|
for (int i = 0; i < numExcluded; i++)
|
||||||
bool found = false;
|
{
|
||||||
if (!numExcluded)
|
excludedRouters.insert (exclude_ident);
|
||||||
{
|
exclude_ident += 32;
|
||||||
auto it = m_LookupResponses.find (ident);
|
|
||||||
if (it != m_LookupResponses.end ())
|
|
||||||
{
|
|
||||||
closestFloodfills = it->second.first;
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found)
|
|
||||||
{
|
|
||||||
std::set<IdentHash> excludedRouters;
|
|
||||||
const uint8_t * exclude_ident = excluded;
|
|
||||||
for (int i = 0; i < numExcluded; i++)
|
|
||||||
{
|
|
||||||
excludedRouters.insert (exclude_ident);
|
|
||||||
exclude_ident += 32;
|
|
||||||
}
|
|
||||||
closestFloodfills = GetClosestFloodfills (ident, 3, excludedRouters, true);
|
|
||||||
if (!numExcluded) // save if no excluded
|
|
||||||
{
|
|
||||||
m_LookupResponses[ident] = std::make_pair(closestFloodfills, i2p::util::GetSecondsSinceEpoch ());
|
|
||||||
if (lookupType != DATABASE_LOOKUP_TYPE_EXPLORATORY_LOOKUP && !closestFloodfills.empty ()) // we are not closest
|
|
||||||
RequestDestination (ident); // try to request for first time only
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
auto closestFloodfills = GetClosestFloodfills (ident, 3, excludedRouters, true);
|
||||||
|
if (closestFloodfills.empty ())
|
||||||
|
LogPrint (eLogWarning, "NetDb: Requested ", key, " not found, ", numExcluded, " peers excluded");
|
||||||
replyMsg = CreateDatabaseSearchReply (ident, closestFloodfills);
|
replyMsg = CreateDatabaseSearchReply (ident, closestFloodfills);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1195,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 + 120) // 2 minutes
|
|
||||||
it = m_LookupResponses.erase (it);
|
|
||||||
else
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
NetDb.h
4
NetDb.h
@ -112,7 +112,6 @@ namespace data
|
|||||||
void Publish ();
|
void Publish ();
|
||||||
void ManageLeaseSets ();
|
void ManageLeaseSets ();
|
||||||
void ManageRequests ();
|
void ManageRequests ();
|
||||||
void ManageLookupResponses ();
|
|
||||||
|
|
||||||
void ReseedFromFloodfill(const RouterInfo & ri, int numRouters=40, int numFloodfills=20);
|
void ReseedFromFloodfill(const RouterInfo & ri, int numRouters=40, int numFloodfills=20);
|
||||||
|
|
||||||
@ -143,8 +142,7 @@ namespace data
|
|||||||
|
|
||||||
/** router info we are bootstrapping from or nullptr if we are not currently doing that*/
|
/** router info we are bootstrapping from or nullptr if we are not currently doing that*/
|
||||||
std::shared_ptr<RouterInfo> m_FloodfillBootstrap;
|
std::shared_ptr<RouterInfo> m_FloodfillBootstrap;
|
||||||
|
|
||||||
std::map<IdentHash, std::pair<std::vector<IdentHash>, uint64_t> > m_LookupResponses; // ident->(closest FFs, timestamp)
|
|
||||||
|
|
||||||
/** true if in hidden mode */
|
/** true if in hidden mode */
|
||||||
bool m_HiddenMode;
|
bool m_HiddenMode;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user