lokinet/llarp/service/lookup.cpp

33 lines
838 B
C++
Raw Permalink Normal View History

#include "lookup.hpp"
2019-01-11 01:19:36 +00:00
#include <llarp/path/path.hpp>
#include <llarp/util/time.hpp>
#include <llarp/router/abstractrouter.hpp>
2019-07-30 23:42:13 +00:00
#include <utility>
2018-08-04 02:59:32 +00:00
2018-07-18 03:10:21 +00:00
namespace llarp
{
struct AbstractRouter;
2018-07-18 03:10:21 +00:00
namespace service
{
IServiceLookup::IServiceLookup(
ILookupHolder* p, uint64_t tx, std::string n, llarp_time_t timeout)
: m_parent(p), txid(tx), name(std::move(n)), m_created{time_now_ms()}, m_timeout{timeout}
2018-08-04 02:59:32 +00:00
{
p->PutLookup(this, tx);
}
2018-07-18 03:10:21 +00:00
bool
IServiceLookup::SendRequestViaPath(path::Path_ptr path, AbstractRouter* r)
2018-07-18 03:10:21 +00:00
{
auto msg = BuildRequestMessage();
if (!msg)
2018-07-18 03:10:21 +00:00
return false;
2021-03-02 15:23:38 +00:00
r->loop()->call(
[path = std::move(path), msg = std::move(msg), r] { path->SendRoutingMessage(*msg, r); });
return true;
2018-07-18 03:10:21 +00:00
}
} // namespace service
2018-10-15 15:43:41 +00:00
} // namespace llarp