diff --git a/llarp/dht/context.cpp b/llarp/dht/context.cpp index 24a07cf3e..27859b088 100644 --- a/llarp/dht/context.cpp +++ b/llarp/dht/context.cpp @@ -484,7 +484,7 @@ namespace llarp const TXOwner asker(OurKey(), txid); const TXOwner peer(askpeer, ++ids); _pendingIntrosetLookups.NewTX( - peer, asker, asker, + peer, asker, peer, new LocalServiceAddressLookup(path, txid, relayOrder, addr, this, askpeer)); } diff --git a/llarp/service/endpoint.cpp b/llarp/service/endpoint.cpp index c3983da62..51d94a8ca 100644 --- a/llarp/service/endpoint.cpp +++ b/llarp/service/endpoint.cpp @@ -982,6 +982,7 @@ namespace llarp llarp_time_t /*timeoutMS*/) { static constexpr size_t NumParalellLookups = 2; + static constexpr size_t RequestsPerLookup = 2; LogInfo(Name(), " Ensure Path to ", remote.ToString()); MarkAddressOutbound(remote); @@ -1005,22 +1006,27 @@ namespace llarp using namespace std::placeholders; size_t lookedUp = 0; const dht::Key_t location = remote.ToKey(); + uint64_t order = 0; for(const auto& path : paths) { - HiddenServiceAddressLookup* job = new HiddenServiceAddressLookup( - this, util::memFn(&Endpoint::OnLookup, this), location, - PubKey{remote.as_array()}, 0, GenTXID()); - LogInfo("doing lookup for ", remote, " via ", path->Endpoint(), " at ", - location); - if(job->SendRequestViaPath(path, Router())) + for(size_t count = 0; count < RequestsPerLookup; ++count) { - lookups.emplace(remote, hook); - lookedUp++; + HiddenServiceAddressLookup* job = new HiddenServiceAddressLookup( + this, util::memFn(&Endpoint::OnLookup, this), location, + PubKey{remote.as_array()}, order, GenTXID()); + LogInfo("doing lookup for ", remote, " via ", path->Endpoint(), + " at ", location, " order=", order); + order++; + if(job->SendRequestViaPath(path, Router())) + { + lookups.emplace(remote, hook); + lookedUp++; + } + else + LogError(Name(), " send via path failed for lookup"); } - else - LogError(Name(), " send via path failed for lookup"); } - return lookedUp == NumParalellLookups; + return lookedUp == (NumParalellLookups * RequestsPerLookup); } bool diff --git a/llarp/service/hidden_service_address_lookup.cpp b/llarp/service/hidden_service_address_lookup.cpp index 4950d2049..d1e2759d0 100644 --- a/llarp/service/hidden_service_address_lookup.cpp +++ b/llarp/service/hidden_service_address_lookup.cpp @@ -16,7 +16,6 @@ namespace llarp , relayOrder(order) , location(l) , handle(std::move(h)) - , requestsSent(0) { } @@ -39,19 +38,7 @@ namespace llarp if(maybe.has_value()) found = maybe.value(); } - handle(remote, found, endpoint); - requestsSent--; - return requestsSent == 0; - } - - bool - HiddenServiceAddressLookup::SendRequestViaPath(path::Path_ptr p, - AbstractRouter* r) - { - if(not IServiceLookup::SendRequestViaPath(p, r)) - return false; - requestsSent += 2; - return true; + return handle(remote, found, endpoint); } std::shared_ptr< routing::IMessage > diff --git a/llarp/service/hidden_service_address_lookup.hpp b/llarp/service/hidden_service_address_lookup.hpp index 76970b660..55be3df13 100644 --- a/llarp/service/hidden_service_address_lookup.hpp +++ b/llarp/service/hidden_service_address_lookup.hpp @@ -18,7 +18,6 @@ namespace llarp using HandlerFunc = std::function< bool( const Address&, nonstd::optional< IntroSet >, const RouterID&) >; HandlerFunc handle; - size_t requestsSent; HiddenServiceAddressLookup(Endpoint* p, HandlerFunc h, const dht::Key_t& location, @@ -27,9 +26,6 @@ namespace llarp ~HiddenServiceAddressLookup() override = default; - bool - SendRequestViaPath(path::Path_ptr p, AbstractRouter* r) override; - bool HandleResponse(const std::set< EncryptedIntroSet >& results) override;