2018-07-11 13:20:14 +00:00
|
|
|
#ifndef LLARP_DHT_NODE_HPP
|
|
|
|
#define LLARP_DHT_NODE_HPP
|
|
|
|
|
2018-12-12 00:48:54 +00:00
|
|
|
#include <dht/key.hpp>
|
2018-12-12 01:55:30 +00:00
|
|
|
#include <router_contact.hpp>
|
2019-04-22 18:35:19 +00:00
|
|
|
#include <service/intro_set.hpp>
|
2019-07-30 23:42:13 +00:00
|
|
|
#include <utility>
|
2018-07-11 13:20:14 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace dht
|
|
|
|
{
|
2019-04-19 15:10:26 +00:00
|
|
|
struct RCNode
|
2018-07-11 13:20:14 +00:00
|
|
|
{
|
2019-01-19 18:16:40 +00:00
|
|
|
RouterContact rc;
|
2018-07-11 13:20:14 +00:00
|
|
|
Key_t ID;
|
|
|
|
|
2018-08-30 18:48:43 +00:00
|
|
|
RCNode()
|
2018-07-11 13:20:14 +00:00
|
|
|
{
|
|
|
|
ID.Zero();
|
|
|
|
}
|
|
|
|
|
2019-01-19 18:16:40 +00:00
|
|
|
RCNode(const RouterContact& other) : rc(other), ID(other.pubkey)
|
2018-07-11 13:20:14 +00:00
|
|
|
{
|
|
|
|
}
|
2018-09-10 17:37:28 +00:00
|
|
|
|
2019-02-11 17:14:43 +00:00
|
|
|
util::StatusObject
|
2019-04-19 15:10:26 +00:00
|
|
|
ExtractStatus() const
|
2019-02-08 19:43:25 +00:00
|
|
|
{
|
2019-02-11 17:14:43 +00:00
|
|
|
return rc.ExtractStatus();
|
2019-02-08 19:43:25 +00:00
|
|
|
}
|
|
|
|
|
2018-09-10 17:37:28 +00:00
|
|
|
bool
|
|
|
|
operator<(const RCNode& other) const
|
|
|
|
{
|
2018-10-08 11:56:17 +00:00
|
|
|
return rc.last_updated < other.rc.last_updated;
|
2018-09-10 17:37:28 +00:00
|
|
|
}
|
2018-07-11 13:20:14 +00:00
|
|
|
};
|
|
|
|
|
2019-04-19 15:10:26 +00:00
|
|
|
struct ISNode
|
2018-07-11 13:20:14 +00:00
|
|
|
{
|
2019-01-19 18:16:40 +00:00
|
|
|
service::IntroSet introset;
|
2018-07-11 13:20:14 +00:00
|
|
|
|
|
|
|
Key_t ID;
|
|
|
|
|
|
|
|
ISNode()
|
|
|
|
{
|
|
|
|
ID.Zero();
|
|
|
|
}
|
|
|
|
|
2019-07-30 23:42:13 +00:00
|
|
|
ISNode(service::IntroSet other) : introset(std::move(other))
|
2018-07-11 13:20:14 +00:00
|
|
|
{
|
2019-01-02 01:03:53 +00:00
|
|
|
introset.A.CalculateAddress(ID.as_array());
|
2018-09-10 17:37:28 +00:00
|
|
|
}
|
|
|
|
|
2019-02-11 17:14:43 +00:00
|
|
|
util::StatusObject
|
2019-04-19 15:10:26 +00:00
|
|
|
ExtractStatus() const
|
2019-02-08 19:43:25 +00:00
|
|
|
{
|
2019-02-11 17:14:43 +00:00
|
|
|
return introset.ExtractStatus();
|
2019-02-08 19:43:25 +00:00
|
|
|
}
|
|
|
|
|
2018-09-10 17:37:28 +00:00
|
|
|
bool
|
|
|
|
operator<(const ISNode& other) const
|
|
|
|
{
|
2018-10-08 11:56:17 +00:00
|
|
|
return introset.T < other.introset.T;
|
2018-07-11 13:20:14 +00:00
|
|
|
}
|
|
|
|
};
|
2018-07-17 04:37:50 +00:00
|
|
|
} // namespace dht
|
|
|
|
} // namespace llarp
|
2018-07-11 13:20:14 +00:00
|
|
|
|
2018-08-30 18:48:43 +00:00
|
|
|
#endif
|