Browse Source

don't send next request if requested destination is over

gha
orignal 3 weeks ago
parent
commit
0ddc514221
  1. 4
      libi2pd/NetDb.cpp
  2. 8
      libi2pd/NetDbRequests.cpp
  3. 3
      libi2pd/NetDbRequests.h

4
libi2pd/NetDb.cpp

@ -741,7 +741,7 @@ namespace data
if (direct) if (direct)
{ {
auto msg = dest->CreateRequestMessage (floodfill->GetIdentHash ()); auto msg = dest->CreateRequestMessage (floodfill->GetIdentHash ());
msg->onDrop = [this, dest]() { this->m_Requests.SendNextRequest (dest); }; msg->onDrop = [this, dest]() { if (dest->IsActive ()) this->m_Requests.SendNextRequest (dest); };
transports.SendMessage (floodfill->GetIdentHash (), msg); transports.SendMessage (floodfill->GetIdentHash (), msg);
} }
else else
@ -752,7 +752,7 @@ namespace data
if (outbound && inbound) if (outbound && inbound)
{ {
auto msg = dest->CreateRequestMessage (floodfill, inbound); auto msg = dest->CreateRequestMessage (floodfill, inbound);
msg->onDrop = [this, dest]() { this->m_Requests.SendNextRequest (dest); }; msg->onDrop = [this, dest]() { if (dest->IsActive ()) this->m_Requests.SendNextRequest (dest); };
outbound->SendTunnelDataMsgTo (floodfill->GetIdentHash (), 0, outbound->SendTunnelDataMsgTo (floodfill->GetIdentHash (), 0,
i2p::garlic::WrapECIESX25519MessageForRouter (msg, floodfill->GetIdentity ()->GetEncryptionPublicKey ())); i2p::garlic::WrapECIESX25519MessageForRouter (msg, floodfill->GetIdentity ()->GetEncryptionPublicKey ()));
} }

8
libi2pd/NetDbRequests.cpp

@ -18,7 +18,7 @@ namespace i2p
namespace data namespace data
{ {
RequestedDestination::RequestedDestination (const IdentHash& destination, bool isExploratory, bool direct): RequestedDestination::RequestedDestination (const IdentHash& destination, bool isExploratory, bool direct):
m_Destination (destination), m_IsExploratory (isExploratory), m_IsDirect (direct), m_Destination (destination), m_IsExploratory (isExploratory), m_IsDirect (direct), m_IsActive (true),
m_CreationTime (i2p::util::GetSecondsSinceEpoch ()), m_LastRequestTime (0) m_CreationTime (i2p::util::GetSecondsSinceEpoch ()), m_LastRequestTime (0)
{ {
} }
@ -60,6 +60,7 @@ namespace data
void RequestedDestination::Success (std::shared_ptr<RouterInfo> r) void RequestedDestination::Success (std::shared_ptr<RouterInfo> r)
{ {
m_IsActive = false;
if (m_RequestComplete) if (m_RequestComplete)
{ {
m_RequestComplete (r); m_RequestComplete (r);
@ -69,6 +70,7 @@ namespace data
void RequestedDestination::Fail () void RequestedDestination::Fail ()
{ {
m_IsActive = false;
if (m_RequestComplete) if (m_RequestComplete)
{ {
m_RequestComplete (nullptr); m_RequestComplete (nullptr);
@ -191,7 +193,7 @@ namespace data
{ {
LogPrint (eLogDebug, "NetDbReq: Try ", dest->GetDestination ().ToBase64 (), " at ", count, " floodfill ", nextFloodfill->GetIdentHash ().ToBase64 (), " directly"); LogPrint (eLogDebug, "NetDbReq: Try ", dest->GetDestination ().ToBase64 (), " at ", count, " floodfill ", nextFloodfill->GetIdentHash ().ToBase64 (), " directly");
auto msg = dest->CreateRequestMessage (nextFloodfill->GetIdentHash ()); auto msg = dest->CreateRequestMessage (nextFloodfill->GetIdentHash ());
msg->onDrop = [this, dest]() { this->SendNextRequest (dest); }; msg->onDrop = [this, dest]() { if (dest->IsActive ()) this->SendNextRequest (dest); };
i2p::transport::transports.SendMessage (nextFloodfill->GetIdentHash (), msg); i2p::transport::transports.SendMessage (nextFloodfill->GetIdentHash (), msg);
} }
else else
@ -203,7 +205,7 @@ namespace data
{ {
LogPrint (eLogDebug, "NetDbReq: Try ", dest->GetDestination ().ToBase64 (), " at ", count, " floodfill ", nextFloodfill->GetIdentHash ().ToBase64 (), " through tunnels"); LogPrint (eLogDebug, "NetDbReq: Try ", dest->GetDestination ().ToBase64 (), " at ", count, " floodfill ", nextFloodfill->GetIdentHash ().ToBase64 (), " through tunnels");
auto msg = dest->CreateRequestMessage (nextFloodfill, inbound); auto msg = dest->CreateRequestMessage (nextFloodfill, inbound);
msg->onDrop = [this, dest]() { this->SendNextRequest (dest); }; msg->onDrop = [this, dest]() { if (dest->IsActive ()) this->SendNextRequest (dest); };
outbound->SendTunnelDataMsgTo (nextFloodfill->GetIdentHash (), 0, outbound->SendTunnelDataMsgTo (nextFloodfill->GetIdentHash (), 0,
i2p::garlic::WrapECIESX25519MessageForRouter (msg, nextFloodfill->GetIdentity ()->GetEncryptionPublicKey ())); i2p::garlic::WrapECIESX25519MessageForRouter (msg, nextFloodfill->GetIdentity ()->GetEncryptionPublicKey ()));
} }

3
libi2pd/NetDbRequests.h

@ -40,6 +40,7 @@ namespace data
void ClearExcludedPeers (); void ClearExcludedPeers ();
bool IsExploratory () const { return m_IsExploratory; }; bool IsExploratory () const { return m_IsExploratory; };
bool IsDirect () const { return m_IsDirect; }; bool IsDirect () const { return m_IsDirect; };
bool IsActive () const { return m_IsActive; };
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; }; uint64_t GetCreationTime () const { return m_CreationTime; };
uint64_t GetLastRequestTime () const { return m_LastRequestTime; }; uint64_t GetLastRequestTime () const { return m_LastRequestTime; };
@ -55,7 +56,7 @@ namespace data
private: private:
IdentHash m_Destination; IdentHash m_Destination;
bool m_IsExploratory, m_IsDirect; bool m_IsExploratory, m_IsDirect, m_IsActive;
std::set<IdentHash> m_ExcludedPeers; std::set<IdentHash> m_ExcludedPeers;
uint64_t m_CreationTime, m_LastRequestTime; // in seconds uint64_t m_CreationTime, m_LastRequestTime; // in seconds
RequestComplete m_RequestComplete; RequestComplete m_RequestComplete;

Loading…
Cancel
Save