mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-13 01:10:24 +00:00
55 lines
1.0 KiB
C++
55 lines
1.0 KiB
C++
#ifndef LLARP_DHT_TXOWNER_HPP
|
|
#define LLARP_DHT_TXOWNER_HPP
|
|
|
|
#include <dht/key.hpp>
|
|
|
|
#include <cstdint>
|
|
|
|
namespace llarp
|
|
{
|
|
namespace dht
|
|
{
|
|
struct TXOwner
|
|
{
|
|
Key_t node;
|
|
uint64_t txid = 0;
|
|
|
|
TXOwner() = default;
|
|
TXOwner(const TXOwner&) = default;
|
|
TXOwner(TXOwner&&) = default;
|
|
|
|
TXOwner&
|
|
operator=(const TXOwner&) = default;
|
|
|
|
TXOwner(const Key_t& k, uint64_t id) : node(k), txid(id)
|
|
{
|
|
}
|
|
|
|
bool
|
|
operator==(const TXOwner& other) const
|
|
{
|
|
return std::tie(txid, node) == std::tie(other.txid, other.node);
|
|
}
|
|
|
|
bool
|
|
operator<(const TXOwner& other) const
|
|
{
|
|
return std::tie(txid, node) < std::tie(other.txid, other.node);
|
|
}
|
|
|
|
struct Hash
|
|
{
|
|
std::size_t
|
|
operator()(const TXOwner& o) const noexcept
|
|
{
|
|
std::size_t sz2;
|
|
memcpy(&sz2, &o.node[0], sizeof(std::size_t));
|
|
return o.txid ^ (sz2 << 1);
|
|
}
|
|
};
|
|
};
|
|
} // namespace dht
|
|
} // namespace llarp
|
|
|
|
#endif
|