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"
|
|
|
|
#include <llarp/router_contact.hpp>
|
|
|
|
#include <llarp/service/intro_set.hpp>
|
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-09-13 19:57:18 +00:00
|
|
|
RCNode(const RouterContact& other) : rc(other), ID(other.pubkey)
|
|
|
|
{}
|
2019-02-08 19:43:25 +00:00
|
|
|
|
2023-09-13 19:57:18 +00:00
|
|
|
util::StatusObject
|
|
|
|
ExtractStatus() const
|
|
|
|
{
|
|
|
|
return rc.ExtractStatus();
|
|
|
|
}
|
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-09-13 19:57:18 +00:00
|
|
|
return rc.last_updated < other.rc.last_updated;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|