dht fixes, disable iterative lookups on clients, revert "fixes" from 0.6.3, pass in recursion depth from introset lookup

pull/1067/head
Jeff Becker 4 years ago
parent d059723f30
commit 3b66cf6e75
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -105,8 +105,8 @@ namespace llarp
/// local path
void
LookupIntroSetForPath(const service::Address& addr, uint64_t txid,
const llarp::PathID_t& path,
const Key_t& askpeer) override;
const llarp::PathID_t& path, const Key_t& askpeer,
uint64_t R) override;
/// send a dht message to peer, if keepalive is true then keep the session
/// with that peer alive for 10 seconds
@ -565,13 +565,14 @@ namespace llarp
void
Context::LookupIntroSetForPath(const service::Address& addr, uint64_t txid,
const llarp::PathID_t& path,
const Key_t& askpeer)
const Key_t& askpeer, uint64_t R)
{
TXOwner asker(OurKey(), txid);
TXOwner peer(askpeer, ++ids);
_pendingIntrosetLookups.NewTX(
peer, asker, addr,
new LocalServiceAddressLookup(path, txid, addr, this, askpeer));
new LocalServiceAddressLookup(path, txid, addr, this, askpeer),
((R + 1) * 2000));
}
void
@ -598,7 +599,8 @@ namespace llarp
TXOwner peer(askpeer, ++ids);
_pendingIntrosetLookups.NewTX(
peer, asker, addr,
new ServiceAddressLookup(asker, addr, this, R, handler), (R * 2000));
new ServiceAddressLookup(asker, addr, this, R, handler),
((R + 1) * 2000));
}
void

@ -88,7 +88,8 @@ namespace llarp
virtual void
LookupIntroSetForPath(const service::Address& addr, uint64_t txid,
const PathID_t& path, const Key_t& askpeer) = 0;
const PathID_t& path, const Key_t& askpeer,
uint64_t R) = 0;
virtual void
DHTSendTo(const RouterID& peer, IMessage* msg, bool keepalive = true) = 0;

@ -105,10 +105,7 @@ namespace llarp
// find closer peer
if(!dht.Nodes()->FindClosest(target, closer))
return false;
if(relayed)
dht.LookupIntroSetForPath(S, T, pathID, closer);
else
replies.emplace_back(new GotIntroMessage(From, closer, T));
replies.emplace_back(new GotIntroMessage(From, closer, T));
return true;
}
@ -118,7 +115,7 @@ namespace llarp
if(dht.Nodes()->FindCloseExcluding(target, peer, exclude))
{
if(relayed)
dht.LookupIntroSetForPath(S, T, pathID, peer);
dht.LookupIntroSetForPath(S, T, pathID, peer, R - 1);
else
{
if((us ^ target) < (peer ^ target))

@ -35,14 +35,14 @@ namespace llarp
}
FindIntroMessage(uint64_t txid, const llarp::service::Address& addr,
bool iterate = true)
bool iterate = false)
: IMessage({}), S(addr), T(txid)
{
N.Zero();
if(iterate)
R = 0;
else
R = 1;
R = 3;
}
~FindIntroMessage() override;

@ -46,7 +46,6 @@ namespace llarp
void
RecursiveRouterLookup::DoNextRequest(const Key_t &peer)
{
peersAsked.emplace(peer);
parent->LookupRouterRecursive(target, whoasked.node, whoasked.txid, peer,
resultHandler);
}
@ -54,7 +53,6 @@ namespace llarp
void
RecursiveRouterLookup::Start(const TXOwner &peer)
{
peersAsked.emplace(peer.node);
parent->DHTSendTo(peer.node.as_array(),
new FindRouterMessage(peer.txid, target));
}
@ -78,7 +76,7 @@ namespace llarp
{
resultHandler(valuesFound);
}
else if(whoasked.node != parent->OurKey())
if(whoasked.node != parent->OurKey())
{
parent->DHTSendTo(
whoasked.node.as_array(),

@ -1,2 +1 @@
#include <router/abstractrouter.hpp>

@ -39,7 +39,7 @@ namespace llarp
{
auto msg = std::make_shared< routing::DHTMessage >();
msg->M.emplace_back(
std::make_unique< dht::FindIntroMessage >(txid, remote, true));
std::make_unique< dht::FindIntroMessage >(txid, remote, false));
return msg;
}

@ -11,7 +11,6 @@ namespace llarp
{
struct MockContext final : public dht::AbstractContext
{
MOCK_CONST_METHOD1(StoreRC, void(const RouterContact));
MOCK_METHOD2(LookupRouter, bool(const RouterID&, RouterLookupHandler));
@ -48,9 +47,9 @@ namespace llarp
void(const RouterID& target, uint64_t txid,
const PathID_t& path, const dht::Key_t& askpeer));
MOCK_METHOD4(LookupIntroSetForPath,
MOCK_METHOD5(LookupIntroSetForPath,
void(const service::Address&, uint64_t, const PathID_t&,
const dht::Key_t&));
const dht::Key_t&, uint64_t));
MOCK_METHOD3(DHTSendTo, void(const RouterID&, dht::IMessage*, bool));

Loading…
Cancel
Save