Class Block

java.lang.Object
com.exonum.client.response.Block

public final class Block
extends java.lang.Object
Exonum block header data structure.

A block is essentially a list of transactions, which is a result of the consensus algorithm (thus authenticated by the supermajority of validators) and is applied atomically to the blockchain state.

This structure only contains the amount of transactions and the transactions root hash as well as other information, but not the transactions themselves.

The JSON representation of this class is compatible with the format used by Exonum.

  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  Block.BlockBuilder  
  • Method Summary

    Modifier and Type Method Description
    static Block.BlockBuilder builder()  
    boolean equals​(java.lang.Object o)  
    java.util.Optional<java.time.ZonedDateTime> getCommitTime()
    Returns the time when the block was committed to the blockchain.
    long getHeight()
    The height of this block which is a distance between the last block and the "genesis" block.
    int getNumTransactions()
    Number of transactions in this block.
    @NonNull com.exonum.binding.common.hash.HashCode getPreviousBlockHash()
    Hash link to the previous block in the blockchain.
    int getProposerId()
    Identifier of the leader node which has proposed the block.
    @NonNull com.exonum.binding.common.hash.HashCode getStateHash()
    Hash of the blockchain state after applying transactions in the block.
    @NonNull com.exonum.binding.common.hash.HashCode getTxRootHash()
    Root hash of the Merkle tree of transactions in this block.
    int hashCode()  
    boolean isEmpty()
    Returns true if this block is empty: contains no transactions.
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • getCommitTime

      public java.util.Optional<java.time.ZonedDateTime> getCommitTime()
      Returns the time when the block was committed to the blockchain. The time is equal to the median time of submission of precommit messages confirming this block by the validators.

      Can be empty if include time parameter is not specified in the request.

    • isEmpty

      public final boolean isEmpty()
      Returns true if this block is empty: contains no transactions.
    • builder

      public static Block.BlockBuilder builder()
    • getProposerId

      public int getProposerId()
      Identifier of the leader node which has proposed the block.
    • getHeight

      public long getHeight()
      The height of this block which is a distance between the last block and the "genesis" block. Genesis block has 0 height. Therefore, the blockchain height is equal to the number of blocks plus one.

      The height also identifies each block in the blockchain.

    • getNumTransactions

      public int getNumTransactions()
      Number of transactions in this block.
    • getPreviousBlockHash

      @NonNull public @NonNull com.exonum.binding.common.hash.HashCode getPreviousBlockHash()
      Hash link to the previous block in the blockchain.
    • getTxRootHash

      @NonNull public @NonNull com.exonum.binding.common.hash.HashCode getTxRootHash()
      Root hash of the Merkle tree of transactions in this block.
    • getStateHash

      @NonNull public @NonNull com.exonum.binding.common.hash.HashCode getStateHash()
      Hash of the blockchain state after applying transactions in the block.
    • equals

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object