Package com.exonum.client.response
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 classBlock.BlockBuilder -
Method Summary
Modifier and Type Method Description static Block.BlockBuilderbuilder()booleanequals(java.lang.Object o)java.util.Optional<java.time.ZonedDateTime>getCommitTime()Returns the time when the block was committed to the blockchain.longgetHeight()The height of this block which is a distance between the last block and the "genesis" block.intgetNumTransactions()Number of transactions in this block.@NonNull com.exonum.binding.common.hash.HashCodegetPreviousBlockHash()Hash link to the previous block in the blockchain.intgetProposerId()Identifier of the leader node which has proposed the block.@NonNull com.exonum.binding.common.hash.HashCodegetStateHash()Hash of the blockchain state after applying transactions in the block.@NonNull com.exonum.binding.common.hash.HashCodegetTxRootHash()Root hash of the Merkle tree of transactions in this block.inthashCode()booleanisEmpty()Returns true if this block is empty: contains no transactions.java.lang.StringtoString()
-
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
-
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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-