Class BlockHeader.Builder

java.lang.Object
com.privatechain.core.model.BlockHeader.Builder
Enclosing class:
BlockHeader

public static final class BlockHeader.Builder extends Object
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 Details

    • version

      public BlockHeader.Builder version(int version)
      Sets the protocol version.
      Parameters:
      version - protocol version (≥ 1)
      Returns:
      this builder
    • bits

      public BlockHeader.Builder bits(int bits)
      Sets the compact difficulty target (PoW).
      Parameters:
      bits - compact target bits
      Returns:
      this builder
    • nonce

      public BlockHeader.Builder nonce(long nonce)
      Sets the proof-of-work nonce.
      Parameters:
      nonce - mining nonce
      Returns:
      this builder
    • merkleRoot

      public BlockHeader.Builder merkleRoot(String merkleRoot)
      Sets the Merkle root hex string.
      Parameters:
      merkleRoot - 64-character hex string
      Returns:
      this builder
    • timestamp

      public BlockHeader.Builder timestamp(Instant timestamp)
      Sets the block timestamp.
      Parameters:
      timestamp - UTC instant of block creation (non-null)
      Returns:
      this builder
    • build

      public BlockHeader build()
      Builds and returns the BlockHeader.
      Returns:
      a new immutable BlockHeader
      Throws:
      IllegalArgumentException - if any field fails validation