2021-03-09 22:24:35 +00:00
|
|
|
#include "context.hpp"
|
|
|
|
#include "dht.h"
|
|
|
|
#include <llarp/router_contact.hpp>
|
2018-06-01 14:08:54 +00:00
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
llarp_dht_context::llarp_dht_context(llarp::AbstractRouter* router)
|
2018-06-01 21:35:17 +00:00
|
|
|
{
|
|
|
|
parent = router;
|
2020-04-07 18:38:56 +00:00
|
|
|
impl = llarp::dht::makeContext();
|
2018-06-01 21:35:17 +00:00
|
|
|
}
|
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
struct llarp_dht_context*
|
|
|
|
llarp_dht_context_new(llarp::AbstractRouter* router)
|
2018-06-01 14:08:54 +00:00
|
|
|
{
|
2018-07-09 12:30:01 +00:00
|
|
|
return new llarp_dht_context(router);
|
|
|
|
}
|
2018-06-01 14:08:54 +00:00
|
|
|
|
2018-07-09 12:30:01 +00:00
|
|
|
void
|
2020-04-07 18:38:56 +00:00
|
|
|
llarp_dht_context_free(struct llarp_dht_context* ctx)
|
2018-07-09 12:30:01 +00:00
|
|
|
{
|
|
|
|
delete ctx;
|
|
|
|
}
|
2018-06-01 14:08:54 +00:00
|
|
|
|
2018-07-09 12:30:01 +00:00
|
|
|
void
|
2020-04-07 18:38:56 +00:00
|
|
|
__llarp_dht_remove_peer(struct llarp_dht_context* ctx, const byte_t* id)
|
2018-07-09 12:30:01 +00:00
|
|
|
{
|
2019-02-22 15:08:00 +00:00
|
|
|
ctx->impl->Nodes()->DelNode(llarp::dht::Key_t(id));
|
2018-07-09 12:30:01 +00:00
|
|
|
}
|
2018-06-01 21:35:17 +00:00
|
|
|
|
2018-07-09 12:30:01 +00:00
|
|
|
void
|
2020-04-07 18:38:56 +00:00
|
|
|
llarp_dht_allow_transit(llarp_dht_context* ctx)
|
2018-07-09 12:30:01 +00:00
|
|
|
{
|
2019-02-22 15:08:00 +00:00
|
|
|
ctx->impl->AllowTransit() = true;
|
2018-07-09 12:30:01 +00:00
|
|
|
}
|
2018-06-13 16:32:34 +00:00
|
|
|
|
2018-07-09 12:30:01 +00:00
|
|
|
void
|
2020-04-07 18:38:56 +00:00
|
|
|
llarp_dht_context_start(struct llarp_dht_context* ctx, const byte_t* key)
|
2018-07-09 12:30:01 +00:00
|
|
|
{
|
2020-02-27 16:37:23 +00:00
|
|
|
ctx->impl->Init(llarp::dht::Key_t(key), ctx->parent);
|
2018-07-09 12:30:01 +00:00
|
|
|
}
|
2018-06-01 21:35:17 +00:00
|
|
|
|
2018-07-09 12:30:01 +00:00
|
|
|
void
|
2020-04-07 18:38:56 +00:00
|
|
|
llarp_dht_lookup_router(struct llarp_dht_context* ctx, struct llarp_router_lookup_job* job)
|
2018-07-09 12:30:01 +00:00
|
|
|
{
|
2020-04-07 18:38:56 +00:00
|
|
|
job->dht = ctx;
|
2018-07-09 12:30:01 +00:00
|
|
|
job->found = false;
|
2018-09-19 12:22:34 +00:00
|
|
|
job->result.Clear();
|
2018-09-21 14:36:06 +00:00
|
|
|
// llarp_rc_clear(&job->result);
|
2018-09-19 12:22:34 +00:00
|
|
|
llarp::LogError("implement me llarp_dht_lookup_router");
|
|
|
|
/*
|
2018-12-10 14:14:55 +00:00
|
|
|
ctx->parent->logic->queue_job(
|
2018-07-09 12:30:01 +00:00
|
|
|
{job, &llarp::dht::Context::queue_router_lookup});
|
2018-09-19 12:22:34 +00:00
|
|
|
*/
|
2018-07-09 12:30:01 +00:00
|
|
|
}
|