Browse Source

delete obsolete requested destination

pull/73/merge
orignal 11 years ago
parent
commit
a01e2213eb
  1. 5
      NetDb.cpp
  2. 5
      NetDb.h

5
NetDb.cpp

@ -29,6 +29,7 @@ namespace data
m_ExcludedPeers.insert (router->GetIdentHash ()); m_ExcludedPeers.insert (router->GetIdentHash ());
m_LastRouter = router; m_LastRouter = router;
m_LastReplyTunnel = replyTunnel; m_LastReplyTunnel = replyTunnel;
m_CreationTime = i2p::util::GetSecondsSinceEpoch ();
return msg; return msg;
} }
@ -39,6 +40,7 @@ namespace data
m_ExcludedPeers.insert (floodfill); m_ExcludedPeers.insert (floodfill);
m_LastRouter = nullptr; m_LastRouter = nullptr;
m_LastReplyTunnel = nullptr; m_LastReplyTunnel = nullptr;
m_CreationTime = i2p::util::GetSecondsSinceEpoch ();
return msg; return msg;
} }
@ -543,9 +545,10 @@ namespace data
void NetDb::Explore (int numDestinations) void NetDb::Explore (int numDestinations)
{ {
// clean up previous exploratories // clean up previous exploratories
uint64_t ts = i2p::util::GetSecondsSinceEpoch ();
for (auto it = m_RequestedDestinations.begin (); it != m_RequestedDestinations.end ();) for (auto it = m_RequestedDestinations.begin (); it != m_RequestedDestinations.end ();)
{ {
if (it->second->IsExploratory ()) if (it->second->IsExploratory () || ts > it->second->GetCreationTime () + 60) // no response for 1 minute
{ {
delete it->second; delete it->second;
it = m_RequestedDestinations.erase (it); it = m_RequestedDestinations.erase (it);

5
NetDb.h

@ -25,7 +25,8 @@ namespace data
RequestedDestination (const IdentHash& destination, bool isLeaseSet, bool isExploratory = false): RequestedDestination (const IdentHash& destination, bool isLeaseSet, bool isExploratory = false):
m_Destination (destination), m_IsLeaseSet (isLeaseSet), m_IsExploratory (isExploratory), m_Destination (destination), m_IsLeaseSet (isLeaseSet), m_IsExploratory (isExploratory),
m_LastRouter (nullptr), m_LastReplyTunnel (nullptr), m_LastOutboundTunnel (nullptr) {}; m_LastRouter (nullptr), m_LastReplyTunnel (nullptr), m_LastOutboundTunnel (nullptr),
m_CreationTime (0) {};
const IdentHash& GetDestination () const { return m_Destination; }; const IdentHash& GetDestination () const { return m_Destination; };
int GetNumExcludedPeers () const { return m_ExcludedPeers.size (); }; int GetNumExcludedPeers () const { return m_ExcludedPeers.size (); };
@ -37,6 +38,7 @@ namespace data
bool IsExploratory () const { return m_IsExploratory; }; bool IsExploratory () const { return m_IsExploratory; };
bool IsLeaseSet () const { return m_IsLeaseSet; }; bool IsLeaseSet () const { return m_IsLeaseSet; };
bool IsExcluded (const IdentHash& ident) const { return m_ExcludedPeers.count (ident); }; bool IsExcluded (const IdentHash& ident) const { return m_ExcludedPeers.count (ident); };
uint64_t GetCreationTime () const { return m_CreationTime; };
I2NPMessage * CreateRequestMessage (const RouterInfo * router, const i2p::tunnel::InboundTunnel * replyTunnel); I2NPMessage * CreateRequestMessage (const RouterInfo * router, const i2p::tunnel::InboundTunnel * replyTunnel);
I2NPMessage * CreateRequestMessage (const IdentHash& floodfill); I2NPMessage * CreateRequestMessage (const IdentHash& floodfill);
@ -51,6 +53,7 @@ namespace data
const RouterInfo * m_LastRouter; const RouterInfo * m_LastRouter;
const i2p::tunnel::InboundTunnel * m_LastReplyTunnel; const i2p::tunnel::InboundTunnel * m_LastReplyTunnel;
i2p::tunnel::OutboundTunnel * m_LastOutboundTunnel; i2p::tunnel::OutboundTunnel * m_LastOutboundTunnel;
uint64_t m_CreationTime;
}; };
class NetDb class NetDb

Loading…
Cancel
Save