Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::chain::block_header Struct Reference

#include <block_header.hpp>

Inheritance diagram for sysio::chain::block_header:
Collaboration diagram for sysio::chain::block_header:

Public Types

using new_producers_type = std::optional<legacy::producer_schedule_type>
 mroot of all delivered action receipts
 

Public Member Functions

 block_header ()=default
 
digest_type digest () const
 
block_id_type calculate_id () const
 
uint32_t block_num () const
 
flat_multimap< uint16_t, block_header_extensionvalidate_and_extract_header_extensions () const
 

Static Public Member Functions

static uint32_t num_from_id (const block_id_type &id)
 

Public Attributes

block_timestamp_type timestamp
 
account_name producer
 
uint16_t confirmed = 1
 
block_id_type previous
 
checksum256_type transaction_mroot
 
checksum256_type action_mroot
 mroot of cycles_summary
 
uint32_t schedule_version = 0
 
new_producers_type new_producers
 
extensions_type header_extensions
 

Detailed Description

Definition at line 26 of file block_header.hpp.

Member Typedef Documentation

◆ new_producers_type

LEGACY SUPPORT - After enabling the wtmsig-blocks extension this field is deprecated and must be empty

Prior to that activation this carries:

The producer schedule version that should validate this block, this is used to indicate that the prior block which included new_producers->version has been marked irreversible and that it the new producer schedule takes effect this block.

Definition at line 57 of file block_header.hpp.

Constructor & Destructor Documentation

◆ block_header()

sysio::chain::block_header::block_header ( )
default

Member Function Documentation

◆ block_num()

uint32_t sysio::chain::block_header::block_num ( ) const
inline

Definition at line 68 of file block_header.hpp.

68{ return num_from_id(previous) + 1; }
static uint32_t num_from_id(const block_id_type &id)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_id()

block_id_type sysio::chain::block_header::calculate_id ( ) const

Definition at line 18 of file block_header.cpp.

19 {
20 // Do not include signed_block_header attributes in id, specifically exclude producer_signature.
21 block_id_type result = digest(); //fc::sha256::hash(*static_cast<const block_header*>(this));
22 result._hash[0] &= 0xffffffff00000000;
23 result._hash[0] += fc::endian_reverse_u32(block_num()); // store the block num in the ID, 160 bits is plenty for the hash
24 return result;
25 }
uint32_t endian_reverse_u32(uint32_t x)
Definition bitutil.hpp:19
fc::sha256 block_id_type
Definition types.hpp:231
digest_type digest() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ digest()

digest_type sysio::chain::block_header::digest ( ) const

Definition at line 8 of file block_header.cpp.

9 {
10 return digest_type::hash(*this);
11 }
static sha256 hash(const char *d, uint32_t dlen)
Definition sha256.cpp:44
Here is the call graph for this function:
Here is the caller graph for this function:

◆ num_from_id()

uint32_t sysio::chain::block_header::num_from_id ( const block_id_type & id)
static

Definition at line 13 of file block_header.cpp.

14 {
15 return fc::endian_reverse_u32(id._hash[0]);
16 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ validate_and_extract_header_extensions()

flat_multimap< uint16_t, block_header_extension > sysio::chain::block_header::validate_and_extract_header_extensions ( ) const

Definition at line 27 of file block_header.cpp.

27 {
29
30 flat_multimap<uint16_t, block_header_extension> results;
31
32 uint16_t id_type_lower_bound = 0;
33
34 for( size_t i = 0; i < header_extensions.size(); ++i ) {
35 const auto& e = header_extensions[i];
36 auto id = e.first;
37
38 SYS_ASSERT( id >= id_type_lower_bound, invalid_block_header_extension,
39 "Block header extensions are not in the correct order (ascending id types required)"
40 );
41
42 auto iter = results.emplace(std::piecewise_construct,
43 std::forward_as_tuple(id),
44 std::forward_as_tuple()
45 );
46
47 auto match = decompose_t::extract<block_header_extension>( id, e.second, iter->second );
48 SYS_ASSERT( match, invalid_block_header_extension,
49 "Block header extension with id type ${id} is not supported",
50 ("id", id)
51 );
52
53 if( match->enforce_unique ) {
54 SYS_ASSERT( i == 0 || id > id_type_lower_bound, invalid_block_header_extension,
55 "Block header extension with id type ${id} is not allowed to repeat",
56 ("id", id)
57 );
58 }
59
60
61 id_type_lower_bound = id;
62 }
63
64 return results;
65 }
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
uint64_t id
Definition code_cache.cpp:0
unsigned short uint16_t
Definition stdint.h:125
extensions_type header_extensions
account_query_db::get_accounts_by_authorizers_result results
Here is the caller graph for this function:

Member Data Documentation

◆ action_mroot

checksum256_type sysio::chain::block_header::action_mroot

Definition at line 45 of file block_header.hpp.

◆ confirmed

uint16_t sysio::chain::block_header::confirmed = 1

By signing this block this producer is confirming blocks [block_num() - confirmed, blocknum()) as being the best blocks for that range and that he has not signed any other statements that would contradict.

No producer should sign a block with overlapping ranges or it is proof of byzantine behavior. When producing a block a producer is always confirming at least the block he is building off of. A producer cannot confirm "this" block, only prior blocks.

Definition at line 40 of file block_header.hpp.

◆ header_extensions

extensions_type sysio::chain::block_header::header_extensions

Definition at line 61 of file block_header.hpp.

◆ new_producers

new_producers_type sysio::chain::block_header::new_producers

Definition at line 60 of file block_header.hpp.

◆ previous

block_id_type sysio::chain::block_header::previous

Definition at line 42 of file block_header.hpp.

◆ producer

account_name sysio::chain::block_header::producer

Definition at line 29 of file block_header.hpp.

◆ schedule_version

uint32_t sysio::chain::block_header::schedule_version = 0

Definition at line 59 of file block_header.hpp.

◆ timestamp

block_timestamp_type sysio::chain::block_header::timestamp

Definition at line 28 of file block_header.hpp.

◆ transaction_mroot

checksum256_type sysio::chain::block_header::transaction_mroot

Definition at line 44 of file block_header.hpp.


The documentation for this struct was generated from the following files: