Consider enum values when computing protocol hash
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <magic_enum.hpp>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <stdexcept>
|
||||
@@ -495,6 +496,20 @@ struct serialization_traits<T, std::enable_if_t<std::is_enum_v<T>>>
|
||||
{
|
||||
h.feed("enum");
|
||||
h.feed(sizeof(T) * 8);
|
||||
h.feed("{");
|
||||
|
||||
bool first = true;
|
||||
for (auto [value, name]: magic_enum::enum_entries<T>())
|
||||
{
|
||||
if (not first)
|
||||
h.feed(",");
|
||||
first = false;
|
||||
|
||||
h.feed(name);
|
||||
h.feed("=");
|
||||
h.feed((std::underlying_type_t<T>)value);
|
||||
}
|
||||
h.feed("}");
|
||||
}
|
||||
|
||||
static void serialize(T value, serialization_packet & packet)
|
||||
|
||||
Reference in New Issue
Block a user