mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-10-31 09:20:21 +00:00
7caa87862e
All #ifndef guards on headers have been removed, I think, in favor of #pragma once Headers are now included as `#include "filename"` if the included file resides in the same directory as the file including it, or any subdirectory therein. Otherwise they are included as `#include <project/top/dir/relative/path/filename>` The above does not include system/os headers.
61 lines
1.2 KiB
C++
61 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include "key.hpp"
|
|
#include <llarp/util/status.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)
|
|
{}
|
|
|
|
util::StatusObject
|
|
ExtractStatus() const
|
|
{
|
|
util::StatusObject obj{
|
|
{"txid", txid},
|
|
{"node", node.ToHex()},
|
|
};
|
|
return obj;
|
|
}
|
|
|
|
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.data(), sizeof(std::size_t));
|
|
return o.txid ^ (sz2 << 1);
|
|
}
|
|
};
|
|
};
|
|
} // namespace dht
|
|
} // namespace llarp
|