Ethereum  PoC-8
The C++ Implementation of Ethereum
dev::eth::BlockHeader Class Reference

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(). More...

#include <BlockHeader.h>

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())
 
 BlockHeader (BlockHeader const &_other)
 
BlockHeaderoperator= (BlockHeader const &_other)
 
 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 (int64_t _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 (int64_t _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
 
bool hasUncles () const
 
int64_t timestamp () const
 
Address const & author () const
 
h256 const & stateRoot () const
 
h256 const & transactionsRoot () const
 
h256 const & receiptsRoot () const
 
u256 const & gasUsed () const
 
int64_t number () const
 
u256 const & gasLimit () const
 
bytes const & extraData () const
 
LogBloom const & logBloom () const
 
u256 const & difficulty () const
 
template<class 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
 

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 96 of file BlockHeader.h.

Constructor & Destructor Documentation

◆ BlockHeader() [1/4]

BlockHeader::BlockHeader ( )

Definition at line 35 of file BlockHeader.cpp.

◆ BlockHeader() [2/4]

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

Definition at line 39 of file BlockHeader.cpp.

◆ BlockHeader() [3/4]

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

Definition at line 104 of file BlockHeader.h.

◆ BlockHeader() [4/4]

BlockHeader::BlockHeader ( BlockHeader const &  _other)

Definition at line 46 of file BlockHeader.cpp.

Member Function Documentation

◆ author()

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

Definition at line 161 of file BlockHeader.h.

◆ clear()

void BlockHeader::clear ( )

Definition at line 100 of file BlockHeader.cpp.

◆ difficulty()

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

Definition at line 170 of file BlockHeader.h.

◆ extractHeader()

RLP BlockHeader::extractHeader ( bytesConstRef  _block)
static

Definition at line 156 of file BlockHeader.cpp.

◆ extraData()

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

Definition at line 168 of file BlockHeader.h.

◆ gasLimit()

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

Definition at line 167 of file BlockHeader.h.

◆ gasUsed()

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

Definition at line 165 of file BlockHeader.h.

◆ hash()

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

Definition at line 119 of file BlockHeader.cpp.

◆ hasUncles()

bool dev::eth::BlockHeader::hasUncles ( ) const
inline

Definition at line 159 of file BlockHeader.h.

◆ headerHashFromBlock() [1/2]

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

Definition at line 108 of file BlockHeader.h.

◆ headerHashFromBlock() [2/2]

h256 BlockHeader::headerHashFromBlock ( bytesConstRef  _block)
static

Definition at line 151 of file BlockHeader.cpp.

◆ logBloom()

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

Definition at line 169 of file BlockHeader.h.

◆ noteDirty()

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

Definition at line 133 of file BlockHeader.h.

◆ number()

int64_t dev::eth::BlockHeader::number ( ) const
inline

Definition at line 166 of file BlockHeader.h.

◆ operator bool()

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

Definition at line 112 of file BlockHeader.h.

◆ operator!=()

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

Definition at line 130 of file BlockHeader.h.

◆ operator=()

BlockHeader & BlockHeader::operator= ( BlockHeader const &  _other)

Definition at line 67 of file BlockHeader.cpp.

◆ operator==()

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

Definition at line 114 of file BlockHeader.h.

◆ parentHash()

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

Definition at line 157 of file BlockHeader.h.

◆ populateFromParent()

void BlockHeader::populateFromParent ( BlockHeader const &  parent)

Definition at line 200 of file BlockHeader.cpp.

◆ receiptsRoot()

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

Definition at line 164 of file BlockHeader.h.

◆ seal()

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

Definition at line 171 of file BlockHeader.h.

◆ setAuthor()

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

Definition at line 146 of file BlockHeader.h.

◆ setDifficulty()

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

Definition at line 153 of file BlockHeader.h.

◆ setExtraData()

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

Definition at line 151 of file BlockHeader.h.

◆ setGasLimit()

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

Definition at line 150 of file BlockHeader.h.

◆ setGasUsed()

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

Definition at line 148 of file BlockHeader.h.

◆ setLogBloom()

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

Definition at line 152 of file BlockHeader.h.

◆ setNumber()

void dev::eth::BlockHeader::setNumber ( int64_t  _v)
inline

Definition at line 149 of file BlockHeader.h.

◆ setParentHash()

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

Definition at line 143 of file BlockHeader.h.

◆ setRoots()

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

Definition at line 147 of file BlockHeader.h.

◆ setSeal() [1/2]

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

Definition at line 155 of file BlockHeader.h.

◆ setSeal() [2/2]

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

Definition at line 154 of file BlockHeader.h.

◆ setSha3Uncles()

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

Definition at line 144 of file BlockHeader.h.

◆ setTimestamp()

void dev::eth::BlockHeader::setTimestamp ( int64_t  _v)
inline

Definition at line 145 of file BlockHeader.h.

◆ sha3Uncles()

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

Definition at line 158 of file BlockHeader.h.

◆ stateRoot()

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

Definition at line 162 of file BlockHeader.h.

◆ streamRLP()

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

Definition at line 139 of file BlockHeader.cpp.

◆ timestamp()

int64_t dev::eth::BlockHeader::timestamp ( ) const
inline

Definition at line 160 of file BlockHeader.h.

◆ transactionsRoot()

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

Definition at line 163 of file BlockHeader.h.

◆ verify() [1/2]

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

Definition at line 138 of file BlockHeader.h.

◆ verify() [2/2]

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

Definition at line 210 of file BlockHeader.cpp.

Friends And Related Function Documentation

◆ BlockChain

friend class BlockChain
friend

Definition at line 98 of file BlockHeader.h.

Member Data Documentation

◆ BasicFields

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

Definition at line 100 of file BlockHeader.h.


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