Class BlockHeader
- All Implemented Interfaces:
RLPLayoutable
public final class BlockHeader extends Object implements RLPLayoutable
-
Field Summary
Fields Modifier and Type Field Description Address
coinbase
Address that will receive the block reward (aka "beneficiary", aka "miner's address").Natural
difficulty
The difficult level of the block, calculated from the previous' block difficulty level and thetimestamp
(cf.byte[]
extraData
An arbitrary byte array containing data relevant to this block.Natural
gasLimit
Current maximum amount of gas usable per block.Natural
gasUsed
The amount of gas used in this block.BloomFilter
logsBloom
The Bloom filter composed from indexable information (logger address and log topics) contained in each log entry from the receipt of each transaction in the transactions list.Hash
mixHash
A hash which, combined with thenonce
, proves that a sufficient amount of computation has been carried out on this block.long
nonce
A 64-bit scalar value which, combined with themixHash
, proves that a sufficient amount of computation has been carried out on this block.Natural
number
The number of ancestor blocks (aka "height").Hash
parentHash
Thehash
of the parent block.MerkleRoot
receiptsRoot
The Merkle root of the receipts list of the block.MerkleRoot
stateRoot
The Merkle root of the state tree.Natural
timestamp
A value equal to the reasonable output of Unix’s time() at this block’s inception.MerkleRoot
transactionsRoot
The Merkle root of the transactions list of the block.Hash
uncleHash
Hash of the the uncles (aka "ommers") list of the block. -
Constructor Summary
Constructors Constructor Description BlockHeader(Hash parentHash, Hash uncleHash, Address coinbase, MerkleRoot stateRoot, MerkleRoot transactionsRoot, MerkleRoot receiptsRoot, BloomFilter logsBloom, Natural difficulty, Natural number, Natural gasLimit, Natural gasUsed, Natural timestamp, byte[] extraData, Hash mixHash, long nonce)
Constructs a header from header data, and computes the header hash from this data. -
Method Summary
Modifier and Type Method Description boolean
equals(Object o)
static BlockHeader
from(RLP rlp)
Parses a RLP sequence into a block header.Hash
hash()
Hash of all the other data in the header.int
hashCode()
boolean
hasUncles()
Return true iff theuncleHash
is not the hash of the empty sequence.RLP
rlpLayout()
Returns the RLP representation of this block header, which is stored in the block (itself RLP-encoded) when circulated over the network.String
toString()
BlockValidityStatus
validate()
Validates the block header against its parent (automatically retrieved fromBlocks.DB
).BlockValidityStatus
validate(BlockHeader parent)
Validates the block header against its parent.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.norswap.nanoeth.rlp.RLPLayoutable
rlpEncode, rlpHexString
-
Field Details
-
parentHash
Thehash
of the parent block.Yellowpaper notation: Hp
-
uncleHash
Hash of the the uncles (aka "ommers") list of the block.Yellowpaper notation: Ho
-
coinbase
Address that will receive the block reward (aka "beneficiary", aka "miner's address").Yellowpaper notation: Hc
-
stateRoot
The Merkle root of the state tree.Yellowpaper notation: Hr
-
transactionsRoot
The Merkle root of the transactions list of the block.Yellowpaper notation: Ht
-
receiptsRoot
The Merkle root of the receipts list of the block.Yellowpaper notation: He
-
logsBloom
The Bloom filter composed from indexable information (logger address and log topics) contained in each log entry from the receipt of each transaction in the transactions list.Yellowpaper notation: Hb
-
difficulty
The difficult level of the block, calculated from the previous' block difficulty level and thetimestamp
(cf.Difficulty
). -
number
The number of ancestor blocks (aka "height"). The genesis block has number 0.Yellowpaper notation: Hi
-
gasLimit
Current maximum amount of gas usable per block.Yellowpaper notation: Hl
A block's miner can choose to update the gas limit incrementally (up or down) within the limit set by the protocol (cf.
validate(BlockHeader)
). -
gasUsed
The amount of gas used in this block.Yellowpaper notation: Hg
-
timestamp
A value equal to the reasonable output of Unix’s time() at this block’s inception.Yellowpaper notation: Hs
The yellowpaper puts a 256 bytes limit on this, but it doesn't seem to affect serialization.
-
extraData
public final byte[] extraDataAn arbitrary byte array containing data relevant to this block. This must be 32 bytes or fewer.Yellowpaper notaion: Hx
-
mixHash
A hash which, combined with thenonce
, proves that a sufficient amount of computation has been carried out on this block.Yellowpaper notation: Hm
-
nonce
public final long nonceA 64-bit scalar value which, combined with themixHash
, proves that a sufficient amount of computation has been carried out on this block.Miners iterate the nonce value until they can find a
mixHash
that satisfies thedifficulty
requirement.Yellowpaper notation: Hn
Note that unlike other scalar values, by like addresses, hashes, ... the nonce gets serialized in full, even if it has leading zeroes.
-
-
Constructor Details
-
BlockHeader
public BlockHeader(Hash parentHash, Hash uncleHash, Address coinbase, MerkleRoot stateRoot, MerkleRoot transactionsRoot, MerkleRoot receiptsRoot, BloomFilter logsBloom, Natural difficulty, Natural number, Natural gasLimit, Natural gasUsed, Natural timestamp, byte[] extraData, Hash mixHash, long nonce)Constructs a header from header data, and computes the header hash from this data.
-
-
Method Details
-
hash
Hash of all the other data in the header. This is not serialized in the block (but will be serialized in the children asparentHash
). This is computed lazily and cached. -
from
Parses a RLP sequence into a block header.- Throws:
RLPParsingException
- if the RLP sequence does not properly parse to a block header
-
validate
Validates the block header against its parent (automatically retrieved fromBlocks.DB
).- Returns:
BlockValidityStatus.VAL_VALID
if the header is valid, or aBlockValidityStatus
value that indicates the reason for the failure.- See Also:
for full block validation, including running the transactions.
-
validate
Validates the block header against its parent. The parent is expected to have been retrieve from this header'sparentHash
(can be null for the genesis block).- Returns:
BlockValidityStatus.VAL_VALID
if the header is valid, or aBlockValidityStatus
value that indicates the reason for the failure.- See Also:
for full block validation, including running the transactions.
-
hasUncles
public boolean hasUncles()Return true iff theuncleHash
is not the hash of the empty sequence. -
rlpLayout
Returns the RLP representation of this block header, which is stored in the block (itself RLP-encoded) when circulated over the network. Uncle block headers are similarly encoded.- Specified by:
rlpLayout
in interfaceRLPLayoutable
-
equals
-
hashCode
public int hashCode() -
toString
-