Class BlockHeader
- All Implemented Interfaces:
RLPLayoutable
public final class BlockHeader extends Object implements RLPLayoutable
-
Field Summary
Fields Modifier and Type Field Description AddresscoinbaseAddress that will receive the block reward (aka "beneficiary", aka "miner's address").NaturaldifficultyThe difficult level of the block, calculated from the previous' block difficulty level and thetimestamp(cf.byte[]extraDataAn arbitrary byte array containing data relevant to this block.NaturalgasLimitCurrent maximum amount of gas usable per block.NaturalgasUsedThe amount of gas used in this block.BloomFilterlogsBloomThe 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.HashmixHashA hash which, combined with thenonce, proves that a sufficient amount of computation has been carried out on this block.longnonceA 64-bit scalar value which, combined with themixHash, proves that a sufficient amount of computation has been carried out on this block.NaturalnumberThe number of ancestor blocks (aka "height").HashparentHashThehashof the parent block.MerkleRootreceiptsRootThe Merkle root of the receipts list of the block.MerkleRootstateRootThe Merkle root of the state tree.NaturaltimestampA value equal to the reasonable output of Unix’s time() at this block’s inception.MerkleRoottransactionsRootThe Merkle root of the transactions list of the block.HashuncleHashHash 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 booleanequals(Object o)static BlockHeaderfrom(RLP rlp)Parses a RLP sequence into a block header.Hashhash()Hash of all the other data in the header.inthashCode()booleanhasUncles()Return true iff theuncleHashis not the hash of the empty sequence.RLPrlpLayout()Returns the RLP representation of this block header, which is stored in the block (itself RLP-encoded) when circulated over the network.StringtoString()BlockValidityStatusvalidate()Validates the block header against its parent (automatically retrieved fromBlocks.DB).BlockValidityStatusvalidate(BlockHeader parent)Validates the block header against its parent.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.norswap.nanoeth.rlp.RLPLayoutable
rlpEncode, rlpHexString
-
Field Details
-
parentHash
Thehashof 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
mixHashthat satisfies thedifficultyrequirement.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_VALIDif the header is valid, or aBlockValidityStatusvalue 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_VALIDif the header is valid, or aBlockValidityStatusvalue that indicates the reason for the failure.- See Also:
for full block validation, including running the transactions.
-
hasUncles
public boolean hasUncles()Return true iff theuncleHashis 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:
rlpLayoutin interfaceRLPLayoutable
-
equals
-
hashCode
public int hashCode() -
toString
-