2021-03-09 22:24:35 +00:00
|
|
|
#pragma once
|
2018-07-11 13:20:14 +00:00
|
|
|
|
2021-03-09 22:24:35 +00:00
|
|
|
#include "key.hpp"
|
2023-10-24 13:18:03 +00:00
|
|
|
|
2021-03-09 22:24:35 +00:00
|
|
|
#include <llarp/router_contact.hpp>
|
|
|
|
#include <llarp/service/intro_set.hpp>
|
2023-10-24 13:18:03 +00:00
|
|
|
|
2019-07-30 23:42:13 +00:00
|
|
|
#include <utility>
|
2018-07-11 13:20:14 +00:00
|
|
|
|
2023-09-13 19:57:18 +00:00
|
|
|
namespace llarp::dht
|
2018-07-11 13:20:14 +00:00
|
|
|
{
|
2023-09-13 19:57:18 +00:00
|
|
|
struct RCNode
|
2018-07-11 13:20:14 +00:00
|
|
|
{
|
2023-09-13 19:57:18 +00:00
|
|
|
RouterContact rc;
|
|
|
|
Key_t ID;
|
2018-07-11 13:20:14 +00:00
|
|
|
|
2023-09-13 19:57:18 +00:00
|
|
|
RCNode()
|
|
|
|
{
|
|
|
|
ID.Zero();
|
|
|
|
}
|
2018-09-10 17:37:28 +00:00
|
|
|
|
2023-10-31 20:49:01 +00:00
|
|
|
RCNode(const RouterContact& other) : rc(other), ID(other.router_id())
|
2023-09-13 19:57:18 +00:00
|
|
|
{}
|
2019-02-08 19:43:25 +00:00
|
|
|
|
2023-09-13 19:57:18 +00:00
|
|
|
util::StatusObject
|
|
|
|
ExtractStatus() const
|
|
|
|
{
|
2023-10-31 20:49:01 +00:00
|
|
|
return rc.extract_status();
|
2023-09-13 19:57:18 +00:00
|
|
|
}
|
2018-07-11 13:20:14 +00:00
|
|
|
|
2023-09-13 19:57:18 +00:00
|
|
|
bool
|
|
|
|
operator<(const RCNode& other) const
|
2018-07-11 13:20:14 +00:00
|
|
|
{
|
2023-10-31 20:49:01 +00:00
|
|
|
return rc.timestamp() < other.rc.timestamp();
|
2023-09-13 19:57:18 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ISNode
|
|
|
|
{
|
|
|
|
service::EncryptedIntroSet introset;
|
2018-07-11 13:20:14 +00:00
|
|
|
|
2023-09-13 19:57:18 +00:00
|
|
|
Key_t ID;
|
2018-07-11 13:20:14 +00:00
|
|
|
|
2023-09-13 19:57:18 +00:00
|
|
|
ISNode()
|
|
|
|
{
|
|
|
|
ID.Zero();
|
|
|
|
}
|
2018-07-11 13:20:14 +00:00
|
|
|
|
2023-09-13 19:57:18 +00:00
|
|
|
ISNode(service::EncryptedIntroSet other) : introset(std::move(other))
|
|
|
|
{
|
|
|
|
ID = Key_t(introset.derivedSigningKey.as_array());
|
|
|
|
}
|
2018-09-10 17:37:28 +00:00
|
|
|
|
2023-09-13 19:57:18 +00:00
|
|
|
util::StatusObject
|
|
|
|
ExtractStatus() const
|
|
|
|
{
|
|
|
|
return introset.ExtractStatus();
|
|
|
|
}
|
2019-02-08 19:43:25 +00:00
|
|
|
|
2023-09-13 19:57:18 +00:00
|
|
|
bool
|
|
|
|
operator<(const ISNode& other) const
|
|
|
|
{
|
|
|
|
return introset.signedAt < other.introset.signedAt;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} // namespace llarp::dht
|