only inform failure or success of introset lookups when all lookups have returned

pull/1658/head
Jeff Becker 3 years ago
parent 220b8837da
commit 34e31ba04f
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -1332,14 +1332,18 @@ namespace llarp
{
LogError(Name(), " failed to lookup ", addr.ToString(), " from ", endpoint);
fails[endpoint] = fails[endpoint] + 1;
// inform one if applicable
// when relay order is non zero we can be pretty sure that it's a fail as when relay order
// is zero that can sometimes yield a fail because it isn't always the closets in keyspace.
if (relayOrder > 0)
const auto pendingForAddr = std::count_if(
m_state->m_PendingLookups.begin(),
m_state->m_PendingLookups.end(),
[addr](const auto& item) -> bool { return item.second->IsFor(addr); });
// inform all if we have no more pending lookups for this address
if (pendingForAddr == 0)
{
auto range = lookups.equal_range(addr);
auto itr = range.first;
if (itr != range.second)
while (itr != range.second)
{
itr->second(addr, nullptr);
itr = lookups.erase(itr);

@ -30,6 +30,16 @@ namespace llarp
~HiddenServiceAddressLookup() override = default;
virtual bool
IsFor(EndpointBase::AddressVariant_t addr) const override
{
if (const auto* ptr = std::get_if<Address>(&addr))
{
return Address{rootkey} == *ptr;
}
return false;
}
bool
HandleIntrosetResponse(const std::set<EncryptedIntroSet>& results) override;

@ -4,6 +4,8 @@
#include "intro_set.hpp"
#include <llarp/path/pathset.hpp>
#include <llarp/endpoint_base.hpp>
#include <set>
namespace llarp
@ -73,6 +75,12 @@ namespace llarp
const std::string name;
RouterID endpoint;
/// return true if this lookup is for a remote address
virtual bool IsFor(EndpointBase::AddressVariant_t) const
{
return false;
}
util::StatusObject
ExtractStatus() const
{

Loading…
Cancel
Save