Big R, little r, what begins with R?

pull/1091/head
Stephen Shelton 4 years ago committed by Jason Rhinelander
parent 4d4b33607f
commit fa1df8db63

@ -50,7 +50,7 @@ namespace llarp
void
LookupIntroSetRecursive(
const Key_t& target, const Key_t& whoasked, uint64_t whoaskedTX,
const Key_t& askpeer, uint64_t R,
const Key_t& askpeer, uint64_t recursionDepth,
service::EncryptedIntroSetLookupHandler result = nullptr) override;
void
@ -94,7 +94,7 @@ namespace llarp
void
LookupIntroSetForPath(const Key_t& addr, uint64_t txid,
const llarp::PathID_t& path, const Key_t& askpeer,
uint64_t R) override;
uint64_t recursionDepth) override;
/// send a dht message to peer, if keepalive is true then keep the session
/// with that peer alive for 10 seconds
@ -488,17 +488,17 @@ namespace llarp
}
void
Context::Init(const Key_t& us, AbstractRouter* r,
Context::Init(const Key_t& us, AbstractRouter* router,
llarp_time_t exploreInterval)
{
router = r;
router = router;
ourKey = us;
_nodes = std::make_unique< Bucket< RCNode > >(ourKey, llarp::randint);
_services = std::make_unique< Bucket< ISNode > >(ourKey, llarp::randint);
llarp::LogDebug("initialize dht with key ", ourKey);
// start exploring
r->logic()->call_later(
router->logic()->call_later(
exploreInterval,
std::bind(&llarp::dht::Context::handle_explore_timer, this,
exploreInterval));
@ -541,14 +541,15 @@ namespace llarp
void
Context::LookupIntroSetForPath(const Key_t& addr, uint64_t txid,
const llarp::PathID_t& path,
const Key_t& askpeer, uint64_t R)
const Key_t& askpeer,
uint64_t recursionDepth)
{
TXOwner asker(OurKey(), txid);
TXOwner peer(askpeer, ++ids);
_pendingIntrosetLookups.NewTX(
peer, asker, addr,
new LocalServiceAddressLookup(path, txid, addr, this, askpeer),
((R + 1) * 2000));
((recursionDepth + 1) * 2000));
}
void
@ -568,15 +569,15 @@ namespace llarp
void
Context::LookupIntroSetRecursive(
const Key_t& addr, const Key_t& whoasked, uint64_t txid,
const Key_t& askpeer, uint64_t R,
const Key_t& askpeer, uint64_t recursionDepth,
service::EncryptedIntroSetLookupHandler handler)
{
TXOwner asker(whoasked, txid);
TXOwner peer(askpeer, ++ids);
_pendingIntrosetLookups.NewTX(
peer, asker, addr,
new ServiceAddressLookup(asker, addr, this, R, handler),
((R + 1) * 2000));
new ServiceAddressLookup(asker, addr, this, recursionDepth, handler),
((recursionDepth + 1) * 2000));
}
void
@ -636,11 +637,11 @@ namespace llarp
}
for(const auto& f : foundRouters)
{
const RouterID r = f.as_array();
const RouterID id = f.as_array();
// discard shit routers
if(router->routerProfiling().IsBadForConnect(r))
if(router->routerProfiling().IsBadForConnect(id))
continue;
closer.emplace_back(r);
closer.emplace_back(id);
}
llarp::LogDebug("Gave ", closer.size(), " routers for exploration");
reply.emplace_back(new GotRouterMessage(txid, closer, false));

@ -47,7 +47,7 @@ namespace llarp
virtual void
LookupIntroSetRecursive(
const Key_t& target, const Key_t& whoasked, uint64_t whoaskedTX,
const Key_t& askpeer, uint64_t R,
const Key_t& askpeer, uint64_t recursionDepth,
service::EncryptedIntroSetLookupHandler result =
service::EncryptedIntroSetLookupHandler()) = 0;
@ -69,7 +69,7 @@ namespace llarp
virtual void
LookupIntroSetForPath(const Key_t& addr, uint64_t txid,
const PathID_t& path, const Key_t& askpeer,
uint64_t R) = 0;
uint64_t recursionDepth) = 0;
virtual void
DHTSendTo(const RouterID& peer, IMessage* msg, bool keepalive = true) = 0;

@ -11,10 +11,10 @@ namespace llarp
{
ServiceAddressLookup::ServiceAddressLookup(
const TXOwner &asker, const Key_t &addr, AbstractContext *ctx,
uint64_t r, service::EncryptedIntroSetLookupHandler handler)
uint64_t recursion, service::EncryptedIntroSetLookupHandler handler)
: TX< Key_t, service::EncryptedIntroSet >(asker, addr, ctx)
, handleResult(std::move(handler))
, R(r)
, recursionDepth(recursion)
{
peersAsked.insert(ctx->OurKey());
}
@ -52,17 +52,18 @@ namespace llarp
void
ServiceAddressLookup::Start(const TXOwner &peer)
{
parent->DHTSendTo(peer.node.as_array(),
new FindIntroMessage(peer.txid, target, R));
parent->DHTSendTo(
peer.node.as_array(),
new FindIntroMessage(peer.txid, target, recursionDepth));
}
void
ServiceAddressLookup::DoNextRequest(const Key_t &ask)
{
if(R)
if(recursionDepth)
{
parent->LookupIntroSetRecursive(target, whoasked.node, whoasked.txid,
ask, R - 1);
ask, recursionDepth - 1);
}
else
{

@ -15,10 +15,10 @@ namespace llarp
struct ServiceAddressLookup : public TX< Key_t, service::EncryptedIntroSet >
{
service::EncryptedIntroSetLookupHandler handleResult;
uint64_t R;
uint64_t recursionDepth;
ServiceAddressLookup(const TXOwner &asker, const Key_t &addr,
AbstractContext *ctx, uint64_t r,
AbstractContext *ctx, uint64_t recursionDepth,
service::EncryptedIntroSetLookupHandler handler);
bool

@ -28,8 +28,9 @@ namespace llarp
void
TagLookup::Start(const TXOwner &peer)
{
parent->DHTSendTo(peer.node.as_array(),
new FindIntroMessage(target, peer.txid, R));
parent->DHTSendTo(
peer.node.as_array(),
new FindIntroMessage(target, peer.txid, recursionDepth));
}
void

@ -11,11 +11,11 @@ namespace llarp
{
struct TagLookup : public TX< service::Tag, service::EncryptedIntroSet >
{
uint64_t R;
uint64_t recursionDepth;
TagLookup(const TXOwner &asker, const service::Tag &tag,
AbstractContext *ctx, uint64_t r)
AbstractContext *ctx, uint64_t recursion)
: TX< service::Tag, service::EncryptedIntroSet >(asker, tag, ctx)
, R(r)
, recursionDepth(recursion)
{
}

Loading…
Cancel
Save