2018-07-11 13:20:14 +00:00
|
|
|
|
|
|
|
#ifndef LLARP_DHT_SEARCH_JOB_HPP
|
|
|
|
#define LLARP_DHT_SEARCH_JOB_HPP
|
|
|
|
#include <llarp/dht.h>
|
|
|
|
#include <llarp/time.h>
|
2018-07-12 13:43:37 +00:00
|
|
|
#include <functional>
|
2018-07-11 13:20:14 +00:00
|
|
|
#include <llarp/dht/key.hpp>
|
2018-07-12 13:43:37 +00:00
|
|
|
#include <llarp/service/IntroSet.hpp>
|
2018-07-11 13:20:14 +00:00
|
|
|
#include <set>
|
2018-07-20 04:50:28 +00:00
|
|
|
#include <vector>
|
2018-07-11 13:20:14 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace dht
|
|
|
|
{
|
2018-07-17 04:37:50 +00:00
|
|
|
/// TODO: this should be made into a templated type
|
2018-07-11 13:20:14 +00:00
|
|
|
struct SearchJob
|
|
|
|
{
|
|
|
|
const static uint64_t JobTimeout = 30000;
|
2018-07-17 04:37:50 +00:00
|
|
|
|
2018-07-20 04:50:28 +00:00
|
|
|
typedef std::function< void(
|
|
|
|
const std::vector< llarp::service::IntroSet >&) >
|
2018-07-12 13:43:37 +00:00
|
|
|
IntroSetHookFunc;
|
2018-07-11 13:20:14 +00:00
|
|
|
SearchJob();
|
2018-07-12 13:43:37 +00:00
|
|
|
/// for routers
|
|
|
|
SearchJob(const Key_t& requester, uint64_t requesterTX,
|
|
|
|
const Key_t& target, const std::set< Key_t >& excludes,
|
|
|
|
llarp_router_lookup_job* job);
|
|
|
|
/// for introsets
|
2018-07-11 13:20:14 +00:00
|
|
|
SearchJob(const Key_t& requester, uint64_t requesterTX,
|
2018-07-12 13:43:37 +00:00
|
|
|
const Key_t& target, const std::set< Key_t >& excludes,
|
|
|
|
IntroSetHookFunc found);
|
2018-07-18 20:58:16 +00:00
|
|
|
// for introsets via tag
|
|
|
|
SearchJob(const Key_t& requester, uint64_t requseterTX,
|
|
|
|
IntroSetHookFunc found);
|
2018-07-12 13:43:37 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
FoundRouter(const llarp_rc* router) const;
|
|
|
|
|
|
|
|
void
|
2018-07-20 04:50:28 +00:00
|
|
|
FoundIntros(
|
|
|
|
const std::vector< llarp::service::IntroSet >& introset) const;
|
2018-07-11 13:20:14 +00:00
|
|
|
|
|
|
|
void
|
2018-07-12 13:43:37 +00:00
|
|
|
Timeout() const;
|
2018-07-11 13:20:14 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
IsExpired(llarp_time_t now) const;
|
|
|
|
|
2018-07-12 13:43:37 +00:00
|
|
|
// only set if looking up router
|
2018-07-11 13:20:14 +00:00
|
|
|
llarp_router_lookup_job* job = nullptr;
|
2018-07-12 13:43:37 +00:00
|
|
|
IntroSetHookFunc foundIntroHook;
|
2018-07-11 13:20:14 +00:00
|
|
|
llarp_time_t started;
|
|
|
|
Key_t requester;
|
|
|
|
uint64_t requesterTX;
|
|
|
|
Key_t target;
|
|
|
|
std::set< Key_t > exclude;
|
|
|
|
};
|
2018-07-12 13:43:37 +00:00
|
|
|
} // namespace dht
|
|
|
|
} // namespace llarp
|
2018-07-11 13:20:14 +00:00
|
|
|
#endif
|