Fabcoin Core  0.16.2
P2P Digital Currency
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
dev::eth::BlockHeader Class Reference

Encapsulation of a block header. More...

#include <BlockHeader.h>

Collaboration diagram for dev::eth::BlockHeader:
[legend]

Public Member Functions

 BlockHeader ()
 
 BlockHeader (bytesConstRef _data, BlockDataType _bdt=BlockData, h256 const &_hashWith=h256())
 
 BlockHeader (bytes const &_data, BlockDataType _bdt=BlockData, h256 const &_hashWith=h256())
 
 operator bool () const
 
bool operator== (BlockHeader const &_cmp) const
 
bool operator!= (BlockHeader const &_cmp) const
 
void clear ()
 
void noteDirty () const
 
void populateFromParent (BlockHeader const &parent)
 
void verify (Strictness _s=CheckEverything, BlockHeader const &_parent=BlockHeader(), bytesConstRef _block=bytesConstRef()) const
 
void verify (Strictness _s, bytesConstRef _block) const
 
h256 hash (IncludeSeal _i=WithSeal) const
 
void streamRLP (RLPStream &_s, IncludeSeal _i=WithSeal) const
 
void setParentHash (h256 const &_v)
 
void setSha3Uncles (h256 const &_v)
 
void setTimestamp (u256 const &_v)
 
void setAuthor (Address const &_v)
 
void setRoots (h256 const &_t, h256 const &_r, h256 const &_u, h256 const &_s)
 
void setGasUsed (u256 const &_v)
 
void setNumber (u256 const &_v)
 
void setGasLimit (u256 const &_v)
 
void setExtraData (bytes const &_v)
 
void setLogBloom (LogBloom const &_v)
 
void setDifficulty (u256 const &_v)
 
template<class T >
void setSeal (unsigned _offset, T const &_value)
 
template<class T >
void setSeal (T const &_value)
 
h256 const & parentHash () const
 
h256 const & sha3Uncles () const
 
u256 const & timestamp () const
 
Address const & author () const
 
h256 const & stateRoot () const
 
h256 const & transactionsRoot () const
 
h256 const & receiptsRoot () const
 
u256 const & gasUsed () const
 
u256 const & number () const
 
u256 const & gasLimit () const
 
bytes const & extraData () const
 
LogBloom const & logBloom () const
 
u256 const & difficulty () const
 
template<class T >
T seal (unsigned _offset=0) const
 

Static Public Member Functions

static h256 headerHashFromBlock (bytes const &_block)
 
static h256 headerHashFromBlock (bytesConstRef _block)
 
static RLP extractHeader (bytesConstRef _block)
 

Static Public Attributes

static const unsigned BasicFields = 13
 

Private Member Functions

void populate (RLP const &_header)
 
void streamRLPFields (RLPStream &_s) const
 

Private Attributes

h256 m_parentHash
 
h256 m_sha3Uncles
 
h256 m_stateRoot
 
h256 m_transactionsRoot
 
h256 m_receiptsRoot
 
LogBloom m_logBloom
 
u256 m_number
 
u256 m_gasLimit
 
u256 m_gasUsed
 
bytes m_extraData
 
u256 m_timestamp = Invalid256
 
Address m_author
 
u256 m_difficulty
 
std::vector< bytesm_seal
 Additional (RLP-encoded) header fields. More...
 
h256 m_hash
 (Memoised) SHA3 hash of the block header with seal. More...
 
h256 m_hashWithout
 (Memoised) SHA3 hash of the block header without seal. More...
 

Friends

class BlockChain
 

Detailed Description

Encapsulation of a block header.

Class to contain all of a block header's data. It is able to parse a block header and populate from some given RLP block serialisation with the static fromHeader(), through the method populate(). This will not conduct any verification above basic formating. In this case extra verification can be performed through verify().

The object may also be populated from an entire block through the explicit constructor BlockHeader(bytesConstRef) and manually with the populate() method. These will conduct verification of the header against the other information in the block.

The object may be populated with a template given a parent BlockHeader object with the populateFromParent() method. The genesis block info may be retrieved with genesis() and the corresponding RLP block created with createGenesisBlock().

To determine the header hash without the nonce (for sealing), the method hash(WithoutNonce) is provided.

The default constructor creates an empty object, which can be tested against with the boolean conversion operator.

Definition at line 95 of file BlockHeader.h.

Constructor & Destructor Documentation

BlockHeader::BlockHeader ( )

Definition at line 34 of file BlockHeader.cpp.

Here is the caller graph for this function:

BlockHeader::BlockHeader ( bytesConstRef  _data,
BlockDataType  _bdt = BlockData,
h256 const &  _hashWith = h256() 
)
explicit

Definition at line 38 of file BlockHeader.cpp.

Here is the call graph for this function:

dev::eth::BlockHeader::BlockHeader ( bytes const &  _data,
BlockDataType  _bdt = BlockData,
h256 const &  _hashWith = h256() 
)
inlineexplicit

Definition at line 103 of file BlockHeader.h.

Member Function Documentation

Address const& dev::eth::BlockHeader::author ( ) const
inline

Definition at line 157 of file BlockHeader.h.

Here is the caller graph for this function:

void BlockHeader::clear ( )

Definition at line 45 of file BlockHeader.cpp.

Here is the caller graph for this function:

u256 const& dev::eth::BlockHeader::difficulty ( ) const
inline

Definition at line 166 of file BlockHeader.h.

Here is the caller graph for this function:

RLP BlockHeader::extractHeader ( bytesConstRef  _block)
static

Definition at line 100 of file BlockHeader.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bytes const& dev::eth::BlockHeader::extraData ( ) const
inline

Definition at line 164 of file BlockHeader.h.

Here is the caller graph for this function:

u256 const& dev::eth::BlockHeader::gasLimit ( ) const
inline

Definition at line 163 of file BlockHeader.h.

Here is the caller graph for this function:

u256 const& dev::eth::BlockHeader::gasUsed ( ) const
inline

Definition at line 161 of file BlockHeader.h.

Here is the caller graph for this function:

h256 BlockHeader::hash ( IncludeSeal  _i = WithSeal) const

Definition at line 64 of file BlockHeader.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static h256 dev::eth::BlockHeader::headerHashFromBlock ( bytes const &  _block)
inlinestatic

Definition at line 105 of file BlockHeader.h.

Here is the call graph for this function:

Here is the caller graph for this function:

h256 BlockHeader::headerHashFromBlock ( bytesConstRef  _block)
static

Definition at line 95 of file BlockHeader.cpp.

Here is the call graph for this function:

LogBloom const& dev::eth::BlockHeader::logBloom ( ) const
inline

Definition at line 165 of file BlockHeader.h.

Here is the caller graph for this function:

void dev::eth::BlockHeader::noteDirty ( ) const
inline

Definition at line 130 of file BlockHeader.h.

Here is the call graph for this function:

Here is the caller graph for this function:

u256 const& dev::eth::BlockHeader::number ( ) const
inline

Definition at line 162 of file BlockHeader.h.

Here is the caller graph for this function:

dev::eth::BlockHeader::operator bool ( ) const
inlineexplicit

Definition at line 109 of file BlockHeader.h.

bool dev::eth::BlockHeader::operator!= ( BlockHeader const &  _cmp) const
inline

Definition at line 127 of file BlockHeader.h.

Here is the call graph for this function:

bool dev::eth::BlockHeader::operator== ( BlockHeader const &  _cmp) const
inline

Definition at line 111 of file BlockHeader.h.

Here is the call graph for this function:

Here is the caller graph for this function:

h256 const& dev::eth::BlockHeader::parentHash ( ) const
inline

Definition at line 154 of file BlockHeader.h.

Here is the caller graph for this function:

void BlockHeader::populate ( RLP const &  _header)
private

Definition at line 115 of file BlockHeader.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void BlockHeader::populateFromParent ( BlockHeader const &  parent)

Definition at line 146 of file BlockHeader.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

h256 const& dev::eth::BlockHeader::receiptsRoot ( ) const
inline

Definition at line 160 of file BlockHeader.h.

Here is the caller graph for this function:

template<class T >
T dev::eth::BlockHeader::seal ( unsigned  _offset = 0) const
inline

Definition at line 167 of file BlockHeader.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void dev::eth::BlockHeader::setAuthor ( Address const &  _v)
inline

Definition at line 143 of file BlockHeader.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void dev::eth::BlockHeader::setDifficulty ( u256 const &  _v)
inline

Definition at line 150 of file BlockHeader.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void dev::eth::BlockHeader::setExtraData ( bytes const &  _v)
inline

Definition at line 148 of file BlockHeader.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void dev::eth::BlockHeader::setGasLimit ( u256 const &  _v)
inline

Definition at line 147 of file BlockHeader.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void dev::eth::BlockHeader::setGasUsed ( u256 const &  _v)
inline

Definition at line 145 of file BlockHeader.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void dev::eth::BlockHeader::setLogBloom ( LogBloom const &  _v)
inline

Definition at line 149 of file BlockHeader.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void dev::eth::BlockHeader::setNumber ( u256 const &  _v)
inline

Definition at line 146 of file BlockHeader.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void dev::eth::BlockHeader::setParentHash ( h256 const &  _v)
inline

Definition at line 140 of file BlockHeader.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void dev::eth::BlockHeader::setRoots ( h256 const &  _t,
h256 const &  _r,
h256 const &  _u,
h256 const &  _s 
)
inline

Definition at line 144 of file BlockHeader.h.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T >
void dev::eth::BlockHeader::setSeal ( unsigned  _offset,
T const &  _value 
)
inline

Definition at line 151 of file BlockHeader.h.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T >
void dev::eth::BlockHeader::setSeal ( T const &  _value)
inline

Definition at line 152 of file BlockHeader.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void dev::eth::BlockHeader::setSha3Uncles ( h256 const &  _v)
inline

Definition at line 141 of file BlockHeader.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void dev::eth::BlockHeader::setTimestamp ( u256 const &  _v)
inline

Definition at line 142 of file BlockHeader.h.

Here is the call graph for this function:

Here is the caller graph for this function:

h256 const& dev::eth::BlockHeader::sha3Uncles ( ) const
inline

Definition at line 155 of file BlockHeader.h.

Here is the caller graph for this function:

h256 const& dev::eth::BlockHeader::stateRoot ( ) const
inline

Definition at line 158 of file BlockHeader.h.

Here is the caller graph for this function:

void BlockHeader::streamRLP ( RLPStream _s,
IncludeSeal  _i = WithSeal 
) const

Definition at line 83 of file BlockHeader.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void BlockHeader::streamRLPFields ( RLPStream _s) const
private

Definition at line 77 of file BlockHeader.cpp.

Here is the caller graph for this function:

u256 const& dev::eth::BlockHeader::timestamp ( ) const
inline

Definition at line 156 of file BlockHeader.h.

Here is the caller graph for this function:

h256 const& dev::eth::BlockHeader::transactionsRoot ( ) const
inline

Definition at line 159 of file BlockHeader.h.

Here is the caller graph for this function:

void BlockHeader::verify ( Strictness  _s = CheckEverything,
BlockHeader const &  _parent = BlockHeader(),
bytesConstRef  _block = bytesConstRef() 
) const

Definition at line 156 of file BlockHeader.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void dev::eth::BlockHeader::verify ( Strictness  _s,
bytesConstRef  _block 
) const
inline

Definition at line 135 of file BlockHeader.h.

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class BlockChain
friend

Definition at line 97 of file BlockHeader.h.

Member Data Documentation

const unsigned dev::eth::BlockHeader::BasicFields = 13
static

Definition at line 99 of file BlockHeader.h.

Address dev::eth::BlockHeader::m_author
private

Definition at line 185 of file BlockHeader.h.

u256 dev::eth::BlockHeader::m_difficulty
private

Definition at line 186 of file BlockHeader.h.

bytes dev::eth::BlockHeader::m_extraData
private

Definition at line 182 of file BlockHeader.h.

u256 dev::eth::BlockHeader::m_gasLimit
private

Definition at line 180 of file BlockHeader.h.

u256 dev::eth::BlockHeader::m_gasUsed
private

Definition at line 181 of file BlockHeader.h.

h256 dev::eth::BlockHeader::m_hash
mutableprivate

(Memoised) SHA3 hash of the block header with seal.

Definition at line 190 of file BlockHeader.h.

h256 dev::eth::BlockHeader::m_hashWithout
mutableprivate

(Memoised) SHA3 hash of the block header without seal.

Definition at line 191 of file BlockHeader.h.

LogBloom dev::eth::BlockHeader::m_logBloom
private

Definition at line 178 of file BlockHeader.h.

u256 dev::eth::BlockHeader::m_number
private

Definition at line 179 of file BlockHeader.h.

h256 dev::eth::BlockHeader::m_parentHash
private

Definition at line 173 of file BlockHeader.h.

h256 dev::eth::BlockHeader::m_receiptsRoot
private

Definition at line 177 of file BlockHeader.h.

std::vector<bytes> dev::eth::BlockHeader::m_seal
private

Additional (RLP-encoded) header fields.

Definition at line 188 of file BlockHeader.h.

h256 dev::eth::BlockHeader::m_sha3Uncles
private

Definition at line 174 of file BlockHeader.h.

h256 dev::eth::BlockHeader::m_stateRoot
private

Definition at line 175 of file BlockHeader.h.

u256 dev::eth::BlockHeader::m_timestamp = Invalid256
private

Definition at line 183 of file BlockHeader.h.

h256 dev::eth::BlockHeader::m_transactionsRoot
private

Definition at line 176 of file BlockHeader.h.


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