mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-15 12:13:24 +00:00
273270916e
This commit reflects changes to clang-format rules. Unfortunately, these rule changes create a massive change to the codebase, which causes an apparent rewrite of git history. Git blame's --ignore-rev flag can be used to ignore this commit when attempting to `git blame` some code.
64 lines
1.0 KiB
C++
64 lines
1.0 KiB
C++
#ifndef LLARP_ROUTER_ID_HPP
|
|
#define LLARP_ROUTER_ID_HPP
|
|
|
|
#include <util/aligned.hpp>
|
|
#include <util/status.hpp>
|
|
|
|
namespace llarp
|
|
{
|
|
struct RouterID : public AlignedBuffer<32>
|
|
{
|
|
static constexpr size_t SIZE = 32;
|
|
|
|
using Data = std::array<byte_t, SIZE>;
|
|
|
|
RouterID()
|
|
{
|
|
}
|
|
|
|
RouterID(const byte_t* buf) : AlignedBuffer<SIZE>(buf)
|
|
{
|
|
}
|
|
|
|
RouterID(const Data& data) : AlignedBuffer<SIZE>(data)
|
|
{
|
|
}
|
|
|
|
util::StatusObject
|
|
ExtractStatus() const;
|
|
|
|
std::string
|
|
ToString() const;
|
|
|
|
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;
|
|
};
|
|
|
|
inline bool
|
|
operator==(const RouterID& lhs, const RouterID& rhs)
|
|
{
|
|
return lhs.as_array() == rhs.as_array();
|
|
}
|
|
|
|
} // namespace llarp
|
|
|
|
#endif
|