Package com.privatechain.core.model
Class BlockHeader.Builder
java.lang.Object
com.privatechain.core.model.BlockHeader.Builder
- Enclosing class:
BlockHeader
Fluent builder for
BlockHeader.
All fields have defaults (version=1, bits=0, nonce=0, merkleRoot=EMPTY, now) so callers only need to set the values they care about.
-
Method Summary
Modifier and TypeMethodDescriptionbits(int bits) Sets the compact difficulty target (PoW).build()Builds and returns theBlockHeader.merkleRoot(String merkleRoot) Sets the Merkle root hex string.nonce(long nonce) Sets the proof-of-work nonce.Sets the block timestamp.version(int version) Sets the protocol version.
-
Method Details
-
version
Sets the protocol version.- Parameters:
version- protocol version (≥ 1)- Returns:
- this builder
-
bits
Sets the compact difficulty target (PoW).- Parameters:
bits- compact target bits- Returns:
- this builder
-
nonce
Sets the proof-of-work nonce.- Parameters:
nonce- mining nonce- Returns:
- this builder
-
merkleRoot
Sets the Merkle root hex string.- Parameters:
merkleRoot- 64-character hex string- Returns:
- this builder
-
timestamp
Sets the block timestamp.- Parameters:
timestamp- UTC instant of block creation (non-null)- Returns:
- this builder
-
build
Builds and returns theBlockHeader.- Returns:
- a new immutable
BlockHeader - Throws:
IllegalArgumentException- if any field fails validation
-