fix up introset lookups

pull/1151/head
Jeff Becker 4 years ago
parent 806d43c34e
commit 8f4362f092
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -484,7 +484,7 @@ namespace llarp
const TXOwner asker(OurKey(), txid); const TXOwner asker(OurKey(), txid);
const TXOwner peer(askpeer, ++ids); const TXOwner peer(askpeer, ++ids);
_pendingIntrosetLookups.NewTX( _pendingIntrosetLookups.NewTX(
peer, asker, asker, peer, asker, peer,
new LocalServiceAddressLookup(path, txid, relayOrder, addr, this, new LocalServiceAddressLookup(path, txid, relayOrder, addr, this,
askpeer)); askpeer));
} }

@ -982,6 +982,7 @@ namespace llarp
llarp_time_t /*timeoutMS*/) llarp_time_t /*timeoutMS*/)
{ {
static constexpr size_t NumParalellLookups = 2; static constexpr size_t NumParalellLookups = 2;
static constexpr size_t RequestsPerLookup = 2;
LogInfo(Name(), " Ensure Path to ", remote.ToString()); LogInfo(Name(), " Ensure Path to ", remote.ToString());
MarkAddressOutbound(remote); MarkAddressOutbound(remote);
@ -1005,22 +1006,27 @@ namespace llarp
using namespace std::placeholders; using namespace std::placeholders;
size_t lookedUp = 0; size_t lookedUp = 0;
const dht::Key_t location = remote.ToKey(); const dht::Key_t location = remote.ToKey();
uint64_t order = 0;
for(const auto& path : paths) for(const auto& path : paths)
{ {
HiddenServiceAddressLookup* job = new HiddenServiceAddressLookup( for(size_t count = 0; count < RequestsPerLookup; ++count)
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()))
{ {
lookups.emplace(remote, hook); HiddenServiceAddressLookup* job = new HiddenServiceAddressLookup(
lookedUp++; 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 bool

@ -16,7 +16,6 @@ namespace llarp
, relayOrder(order) , relayOrder(order)
, location(l) , location(l)
, handle(std::move(h)) , handle(std::move(h))
, requestsSent(0)
{ {
} }
@ -39,19 +38,7 @@ namespace llarp
if(maybe.has_value()) if(maybe.has_value())
found = maybe.value(); found = maybe.value();
} }
handle(remote, found, endpoint); return 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;
} }
std::shared_ptr< routing::IMessage > std::shared_ptr< routing::IMessage >

@ -18,7 +18,6 @@ namespace llarp
using HandlerFunc = std::function< bool( using HandlerFunc = std::function< bool(
const Address&, nonstd::optional< IntroSet >, const RouterID&) >; const Address&, nonstd::optional< IntroSet >, const RouterID&) >;
HandlerFunc handle; HandlerFunc handle;
size_t requestsSent;
HiddenServiceAddressLookup(Endpoint* p, HandlerFunc h, HiddenServiceAddressLookup(Endpoint* p, HandlerFunc h,
const dht::Key_t& location, const dht::Key_t& location,
@ -27,9 +26,6 @@ namespace llarp
~HiddenServiceAddressLookup() override = default; ~HiddenServiceAddressLookup() override = default;
bool
SendRequestViaPath(path::Path_ptr p, AbstractRouter* r) override;
bool bool
HandleResponse(const std::set< EncryptedIntroSet >& results) override; HandleResponse(const std::set< EncryptedIntroSet >& results) override;

Loading…
Cancel
Save