1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00
lokinet/llarp/router_id.hpp

64 lines
1 KiB
C++
Raw Normal View History

2018-06-10 16:05:48 +02:00
#ifndef LLARP_ROUTER_ID_HPP
#define LLARP_ROUTER_ID_HPP
#include <util/aligned.hpp>
2019-02-11 18:14:43 +01:00
#include <util/status.hpp>
2018-06-10 16:05:48 +02:00
namespace llarp
{
struct RouterID : public AlignedBuffer<32>
{
static constexpr size_t SIZE = 32;
using Data = std::array<byte_t, SIZE>;
2019-08-27 01:29:17 +02:00
RouterID()
{
}
RouterID(const byte_t* buf) : AlignedBuffer<SIZE>(buf)
{
}
RouterID(const Data& data) : AlignedBuffer<SIZE>(data)
{
}
2019-02-11 18:14:43 +01:00
util::StatusObject
2019-04-19 17:10:26 +02:00
ExtractStatus() const;
2019-02-11 18:14:43 +01:00
std::string
ToString() const;
2020-03-01 01:26:23 +01:00
std::string
ShortString() const;
bool
FromString(const std::string& str);
RouterID&
operator=(const byte_t* ptr)
{
std::copy(ptr, ptr + SIZE, begin());
return *this;
}
friend std::ostream&
operator<<(std::ostream& out, const RouterID& id)
{
return out << id.ToString();
}
using Hash = AlignedBuffer<SIZE>::Hash;
};
2019-01-23 00:50:26 +01:00
inline bool
operator==(const RouterID& lhs, const RouterID& rhs)
{
return lhs.as_array() == rhs.as_array();
}
} // namespace llarp
2018-06-10 16:05:48 +02:00
#endif