Put generic_owner hash with the type itself

This is a tiny, one-line function; having it in tx_extra.h with the
actual type definition seems fine.
This commit is contained in:
Jason Rhinelander 2020-04-27 20:14:28 -03:00
parent e5648deacc
commit 89f6928197
2 changed files with 9 additions and 11 deletions

View File

@ -143,6 +143,14 @@ static_assert(sizeof(crypto::ed25519_signature) == sizeof(crypto::signature), "L
inline std::ostream &operator<<(std::ostream &o, const generic_signature &v) { epee::to_hex::formatted(o, epee::as_byte_span(v.data)); return o; }
}
namespace std {
static_assert(sizeof(lns::generic_owner) >= sizeof(std::size_t) && alignof(lns::generic_owner) >= alignof(std::size_t),
"Size and alignment of hash must be at least that of size_t");
template <> struct hash<lns::generic_owner> {
std::size_t operator()(const lns::generic_owner &v) const { return reinterpret_cast<const std::size_t &>(v); }
};
}
namespace service_nodes {
enum class new_state : uint16_t
{
@ -152,7 +160,7 @@ namespace service_nodes {
ip_change_penalty,
_count,
};
};
}
namespace cryptonote
{

View File

@ -74,16 +74,6 @@ namespace
}
}
namespace std
{
template <>
struct hash<lns::generic_owner>
{
static_assert(sizeof(lns::generic_owner) >= sizeof(std::size_t) && alignof(lns::generic_owner) >= alignof(std::size_t),
"Size and alignment of hash must be at least that of size_t");
std::size_t operator()(const lns::generic_owner &v) const { return reinterpret_cast<const std::size_t &>(v); }
};
} // namespace std
namespace string_tools = epee::string_tools;