src/primitives/block_data.hpp¶
Namespaces¶
| Name |
|---|
| sgns |
| sgns::primitives |
Classes¶
| Name | |
|---|---|
| struct | sgns::primitives::BlockData |
Functions¶
| Name | |
|---|---|
| bool | operator==(const BlockData & lhs, const BlockData & rhs) compares two BlockData instances |
| template <class Stream ,typename =std::enable_if_t Stream & |
operator<<(Stream & s, const BlockData & v) outputs object of type BlockData to stream |
| template <class Stream ,typename =std::enable_if_t Stream & |
operator>>(Stream & s, BlockData & v) decodes object of type BlockData from stream |
Functions Documentation¶
function operator==¶
compares two BlockData instances
Parameters:
- lhs first instance
- rhs second instance
Return: true if equal false otherwise
function operator<<¶
template <class Stream ,
typename =std::enable_if_t<Stream::is_encoder_stream>>
Stream & operator<<(
Stream & s,
const BlockData & v
)
outputs object of type BlockData to stream
Parameters:
- s stream reference
- v value to output
Template Parameters:
- Stream output stream type
Return: reference to stream
function operator>>¶
template <class Stream ,
typename =std::enable_if_t<Stream::is_decoder_stream>>
Stream & operator>>(
Stream & s,
BlockData & v
)
decodes object of type BlockData from stream
Parameters:
- s stream reference
- v value to decode
Template Parameters:
- Stream input stream type
Return: reference to stream
Source code¶
#ifndef SUPERGENIUS_SRC_PRIMITIVES_BLOCK_DATA_HPP
#define SUPERGENIUS_SRC_PRIMITIVES_BLOCK_DATA_HPP
#include <boost/optional.hpp>
#include "primitives/block.hpp"
#include "primitives/justification.hpp"
namespace sgns::primitives {
struct BlockData {
primitives::BlockHash hash;
boost::optional<primitives::BlockHeader> header;
boost::optional<primitives::BlockBody> body;
boost::optional<base::Buffer> receipt;
boost::optional<base::Buffer> message_queue;
boost::optional<primitives::Justification> justification;
boost::optional<primitives::Block> toBlock() const {
if (!header) {
return boost::none;
}
return body ? primitives::Block{*header, *body}
: primitives::Block{*header};
}
};
inline bool operator==(const BlockData &lhs, const BlockData &rhs) {
return lhs.hash == rhs.hash && lhs.header == rhs.header
&& lhs.body == rhs.body && lhs.receipt == rhs.receipt
&& lhs.message_queue == rhs.message_queue
&& lhs.justification == rhs.justification;
}
template <class Stream,
typename = std::enable_if_t<Stream::is_encoder_stream>>
Stream &operator<<(Stream &s, const BlockData &v) {
return s << v.hash << v.header << v.body << v.receipt << v.message_queue
<< v.justification;
}
template <class Stream,
typename = std::enable_if_t<Stream::is_decoder_stream>>
Stream &operator>>(Stream &s, BlockData &v) {
return s >> v.hash >> v.header >> v.body >> v.receipt >> v.message_queue
>> v.justification;
}
} // namespace sgns::primitives
#endif // SUPERGENIUS_SRC_PRIMITIVES_BLOCK_DATA_HPP
Updated on 2026-03-04 at 13:10:44 -0800