6 #ifndef KAGOME_CORE_NETWORK_TYPES_BLOCK_ATTRIBUTES_HPP 7 #define KAGOME_CORE_NETWORK_TYPES_BLOCK_ATTRIBUTES_HPP 13 #include "scale/scale_error.hpp" 45 : attributes(static_cast<uint8_t>(attribute)) {}
47 template <
typename T,
typename = std::enable_if<std::is_
unsigned_v<T>>>
57 template <
typename T,
typename = std::enable_if<std::is_
unsigned_v<T>>>
58 constexpr
void load(T value) {
59 attributes = mask_ & value;
63 attributes =
static_cast<uint8_t
>(attribute);
77 result.
attributes = attributes |
static_cast<uint8_t
>(attribute);
87 attributes |=
static_cast<uint8_t
>(attribute);
101 result.
attributes = attributes &
static_cast<uint8_t
>(attribute);
111 attributes &=
static_cast<uint8_t
>(attribute);
125 inline operator bool()
const {
126 return attributes != 0;
129 template <
typename T,
typename = std::enable_if<std::is_
unsigned_v<T>>>
130 inline operator T()
const {
135 static constexpr uint8_t mask_ = 0b00011111;
136 uint8_t attributes = 0;
143 BlockAttributes result;
144 result.
load(static_cast<uint8_t>(lhs) | static_cast<uint8_t>(rhs));
149 BlockAttributes result;
150 result.
load(~static_cast<uint8_t>(attribute));
162 typename = std::enable_if_t<Stream::is_encoder_stream>>
164 return s << static_cast<uint8_t>(v);
175 typename = std::enable_if_t<Stream::is_decoder_stream>>
180 attributes.
load(value);
181 if ((uint8_t)attributes != value) {
190 struct std::hash<
kagome::network::BlockAttributes> {
196 #endif // KAGOME_CORE_NETWORK_TYPES_BLOCK_ATTRIBUTES_HPP Include block message queue.
Include a justification for the block.
void raise(T t)
throws outcome::result error as boost exception
auto operator()(const kagome::network::BlockAttributes &attr) const
Stream & operator>>(Stream &s, BlockAttributes &attributes)
BlockAttributes & operator&=(BlockAttribute attribute)
constexpr BlockAttributes operator&(const BlockAttribute &attribute) const
constexpr BlockAttributes(T attribute) noexcept
bool operator==(const BlockAttributes &other) const
Stream & operator<<(Stream &s, const BlockAttributes &v)
outputs object of type BlockAttributes to stream
constexpr BlockAttributes operator&(const BlockAttributes &other) const
BlockAttributes & operator|=(const BlockAttribute &attribute)
constexpr BlockAttributes(BlockAttribute attribute) noexcept
constexpr BlockAttributes operator|(const BlockAttribute &attribute) const
constexpr BlockAttributes operator|(const BlockAttributes &other) const
constexpr BlockAttributes operator~(const BlockAttribute &attribute)
constexpr BlockAttributes operator|(const BlockAttribute &lhs, const BlockAttribute &rhs)
constexpr void load(T value)
BlockAttributes & operator|=(const BlockAttributes &other)
BlockAttributes & operator=(BlockAttribute attribute)
libp2p::connection::Stream Stream
BlockAttributes operator~() const
BlockAttributes & operator&=(const BlockAttributes &other)