src/primitives/block.hpp¶
Namespaces¶
| Name |
|---|
| sgns |
| sgns::primitives |
Classes¶
| Name | |
|---|---|
| struct | sgns::primitives::Block Block primitive consisting of a header and extrinsics. |
Types¶
| Name | |
|---|---|
| using std::vector< Extrinsic > | BlockBody |
Functions¶
| Name | |
|---|---|
| template <class Stream ,typename =std::enable_if_t Stream & |
operator<<(Stream & s, const Block & b) outputs object of type Block to stream |
| template <class Stream ,typename =std::enable_if_t Stream & |
operator>>(Stream & s, Block & b) decodes object of type Block from stream |
Types Documentation¶
using BlockBody¶
Functions Documentation¶
function operator<<¶
template <class Stream ,
typename =std::enable_if_t<Stream::is_encoder_stream>>
Stream & operator<<(
Stream & s,
const Block & b
)
outputs object of type Block to stream
Parameters:
- s stream reference
- b 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,
Block & b
)
decodes object of type Block from stream
Parameters:
- s stream reference
- b value to decode
Template Parameters:
- Stream input stream type
Return: reference to stream
Source code¶
#ifndef SUPERGENIUS_PRIMITIVES_BLOCK_HPP
#define SUPERGENIUS_PRIMITIVES_BLOCK_HPP
#include "primitives/block_header.hpp"
#include "primitives/extrinsic.hpp"
namespace sgns::primitives {
using BlockBody = std::vector<Extrinsic>;
struct Block {
BlockHeader header;
BlockBody body{};
inline bool operator==(const Block &rhs) const {
return header == rhs.header && body == rhs.body;
}
inline bool operator!=(const Block &rhs) const {
return !operator==(rhs);
}
//added by Jin to fix link error in test mode
friend std::ostream &operator<<(std::ostream &out, const Block &b)
{
out << b.header;
out << b.body.size();
for ( const auto &it : b.body )
{
out << it;
}
return out ;
}
//end
};
template <class Stream,
typename = std::enable_if_t<Stream::is_encoder_stream>>
Stream &operator<<(Stream &s, const Block &b) {
return s << b.header << b.body;
}
template <class Stream,
typename = std::enable_if_t<Stream::is_decoder_stream>>
Stream &operator>>(Stream &s, Block &b) {
return s >> b.header >> b.body;
}
} // namespace sgns::primitives
#endif // SUPERGENIUS_PRIMITIVES_BLOCK_HPP
Updated on 2026-03-04 at 13:10:44 -0800