dht tweaks

pull/7/head
Jeff Becker 6 years ago
parent 6bd2e965fc
commit 7622f6cef1

@ -62,6 +62,11 @@ namespace llarp
LookupIntroSetForPath(const service::Address& addr, uint64_t txid,
const llarp::PathID_t& path, const Key_t& askpeer);
void
LookupIntroSetRelayed(const Key_t& requester, uint64_t txid,
const service::Address& addr, bool recursive,
std::vector< IMessage* >& reply);
std::set< service::IntroSet >
FindRandomIntroSetsWithTag(const service::Tag& tag, size_t max = 2);

@ -52,6 +52,11 @@ namespace llarp
PathID_t pathID;
llarp_router *m_router;
std::set< service::IntroSet > localIntroSets;
std::set< Key_t > asked;
service::Tag tag;
service::Address addr;
PathLookupJob(llarp_router *r, const PathID_t &localpath, uint64_t tx)
: txid(tx), pathID(localpath), m_router(r)
{

@ -126,8 +126,12 @@ namespace llarp
{
if(relayed)
dht.LookupIntroSetForPath(S, T, pathID, peer);
else
else if((peer ^ dht.OurKey())
> (peer
^ From)) // peer is closer than us, recursive search
dht.LookupIntroSet(S, From, T, peer);
else // we are closer than peer so do iterative search
dht.LookupIntroSet(S, From, T, peer, true);
}
else
{

@ -67,6 +67,7 @@ namespace llarp
return false;
}
dht.services->PutNode(I);
llarp::LogInfo("Put Introset for ", I.A.Addr().ToString());
replies.push_back(new GotIntroMessage({I}, txID));
Key_t peer;
std::set< Key_t > exclude;

@ -88,5 +88,11 @@ int
llarp_ev_udp_sendto(struct llarp_udp_io *udp, const sockaddr *to,
const void *buf, size_t sz)
{
return static_cast< llarp::ev_io * >(udp->impl)->sendto(to, buf, sz);
auto ret = static_cast< llarp::ev_io * >(udp->impl)->sendto(to, buf, sz);
if(ret == -1)
{
llarp::LogWarn("sendto failed ", strerror(errno));
errno = 0;
}
return ret;
}

@ -21,17 +21,14 @@ frame_state::process_inbound_queue()
InboundMessage::OrderCompare >
q;
recvqueue.Process(q);
uint64_t last = 0;
while(q.size())
{
// TODO: is this right?
auto &front = q.top();
if(front->msgid < nextMsgID && nextMsgID - front->msgid > 1)
{
// re-queue because of an ordering gap
recvqueue.Put(front);
}
else
if(last != front->msgid)
{
auto buffer = front->Buffer();
if(!Router()->HandleRecvLinkMessage(parent, buffer))
@ -39,12 +36,14 @@ frame_state::process_inbound_queue()
llarp::LogWarn("failed to process inbound message ", front->msgid);
llarp::DumpBuffer< llarp_buffer_t, 128 >(buffer);
}
else
{
nextMsgID = std::max(front->msgid, nextMsgID + 1);
}
delete front;
last = front->msgid;
}
else
{
llarp::LogWarn("duplicate inbound message ", last);
}
delete front;
q.pop();
}
// TODO: this isn't right

@ -499,8 +499,8 @@ llarp_router::on_try_connect_result(llarp_link_establish_job *job)
if(job->session)
{
// llarp::LogDebug("try_connect got session");
auto session = job->session;
router->async_verify_RC(session->get_remote_router(), false, job);
// auto session = job->session;
// router->async_verify_RC(session->get_remote_router(), false, job);
return;
}
// llarp::LogDebug("try_connect no session");
@ -573,7 +573,6 @@ llarp_router::async_verify_RC(llarp_rc *rc, bool isExpectingClient,
job->hook = &llarp_router::on_verify_client_rc;
else
job->hook = &llarp_router::on_verify_server_rc;
llarp_nodedb_async_verify(job);
}

Loading…
Cancel
Save