try deferred resolve for exit handler

pull/737/head
Jeff Becker 5 years ago
parent 697ece64cc
commit b29ec20ad4
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -171,10 +171,20 @@ namespace llarp
}
else if(m_SNodeKeys.find(pubKey) == m_SNodeKeys.end())
{
// we do not have it mapped
// map it
ip = ObtainServiceNodeIP(r);
msg.AddINReply(ip, isV6);
// we do not have it mapped, async obtain it
ObtainSNodeSession(
r, [&](std::shared_ptr< exit::BaseSession > session) {
if(session && session->IsReady())
{
msg.AddINReply(m_KeyToIP[pubKey], isV6);
}
else
{
msg.AddNXReply();
}
reply(msg);
});
return;
}
else
{
@ -196,6 +206,14 @@ namespace llarp
return true;
}
void
ExitEndpoint::ObtainSNodeSession(const RouterID &router,
exit::SessionReadyFunc obtainCb)
{
ObtainServiceNodeIP(router);
m_SNodeSessions[router]->AddReadyHook(obtainCb);
}
llarp_time_t
ExitEndpoint::Now() const
{

@ -120,6 +120,11 @@ namespace llarp
huint128_t
ObtainServiceNodeIP(const RouterID& router);
/// async obtain snode session and call callback when it's ready to send
void
ObtainSNodeSession(const RouterID& router,
exit::SessionReadyFunc obtainCb);
bool
QueueSNodePacket(const llarp_buffer_t& buf, huint128_t from);

Loading…
Cancel
Save