Class Block
The complete block including all block contents and action evaluation.
Inheritance
Implements
Namespace: Libplanet.Types.Blocks
Assembly: Libplanet.Types.dll
Syntax
public sealed class Block : object, IPreEvaluationBlock, IBlockContent, IBlockHeader, IPreEvaluationBlockHeader, IBlockMetadata, IBlockExcerpt
Constructors
| Improve this Doc View SourceBlock(IBlockHeader, IEnumerable<Transaction>, IEnumerable<EvidenceBase>)
Creates a Block instance by combining a block header
and transactions
.
Declaration
public Block(IBlockHeader header, IEnumerable<Transaction> transactions, IEnumerable<EvidenceBase> evidence)
Parameters
Type | Name | Description |
---|---|---|
IBlock |
header | The block header. |
IEnumerable<Transaction> | transactions | The transactions to include. |
IEnumerable<Evidence |
evidence | The evidence to include. |
Exceptions
Type | Condition |
---|---|
Invalid |
Thrown when
the |
Invalid |
Thrown when the |
Invalid |
Thrown when any tx signature is invalid or not signed by its signer. |
Invalid |
Thrown when the same tx nonce is used by
a signer twice or more, or a tx nonce is used without its previous nonce by a signer.
Note that this validates only a block's intrinsic integrity between its transactions,
but does not guarantee integrity between blocks. Such validation needs to be conducted
by |
Invalid |
Thrown when transactions to set have inconsistent genesis hashes. |
Invalid |
Thrown when the given block
|
Invalid |
Thrown when the given
|
Block(PreEvaluationBlock, (HashDigest<SHA256> StateRootHash, Nullable<ImmutableArray<Byte>> Signature, BlockHash Hash))
Creates a Block instance by combining
a preEvaluationBlock
, its corresponding
proof.StateRootHash.StateRootHash
, valid proof.Signature.Signature
,
and correctly derived proof.Hash.Hash
.
Declaration
public Block(PreEvaluationBlock preEvaluationBlock, (HashDigest<SHA256> StateRootHash, ImmutableArray<byte>? Signature, BlockHash Hash) proof)
Parameters
Type | Name | Description |
---|---|---|
Pre |
preEvaluationBlock | A pre-evaluation block. |
System. |
proof | A triple of the state root hash, the block signature, and the block hash. |
Fields
| Improve this Doc View SourceCurrentProtocolVersion
The latest protocol version.
Declaration
public const int CurrentProtocolVersion = null
Field Value
Type | Description |
---|---|
System. |
Properties
| Improve this Doc View SourceEvidence
The complete block including all block contents and action evaluation.
Declaration
public IReadOnlyList<EvidenceBase> Evidence { get; }
Property Value
Type | Description |
---|---|
IRead |
EvidenceHash
Committing Evidence
Declaration
public HashDigest<SHA256>? EvidenceHash { get; }
Property Value
Type | Description |
---|---|
System. |
Hash
A block's hash.
Declaration
public BlockHash Hash { get; }
Property Value
Type | Description |
---|---|
Block |
See Also
| Improve this Doc View SourceHeader
The Block
Declaration
public BlockHeader Header { get; }
Property Value
Type | Description |
---|---|
Block |
Index
The height of the block.
Declaration
public long Index { get; }
Property Value
Type | Description |
---|---|
System. |
Remarks
Zero means it is a genesis block. Not allowed to be negative.
See Also
| Improve this Doc View SourceLastCommit
The Block
Declaration
public BlockCommit LastCommit { get; }
Property Value
Type | Description |
---|---|
Block |
Miner
The address of the miner.
Declaration
public Address Miner { get; }
Property Value
Type | Description |
---|---|
Address |
PreEvaluationHash
The hash derived from the block except of its state root hash (i.e., without action evaluation).
Declaration
public HashDigest<SHA256> PreEvaluationHash { get; }
Property Value
Type | Description |
---|---|
Hash |
PreviousHash
The previous block's hash. If it's a genesis block (i.e., its Index is 0) this must be null.
Declaration
public BlockHash? PreviousHash { get; }
Property Value
Type | Description |
---|---|
System. |
ProtocolVersion
The protocol version number. For the latest protocol version, see
Current
- 0: The initial block protocol version number. This is not actually recorded in storage. That is, the lack of block protocol version in a stored block means it is of version 0.
-
1: Introduced to be stored with the block data. Validation for
Pre
Evaluation was added.Hash -
2: Updated to include Signature to blocks. As a result,
the miner's identity is provided as a Public
Key instead of a Address. Additionally, total difficulty was added. - 3: Updated to fix an issue with the internal execution ordering of Transactions in blocks.
-
4: Updated to introduce a PBFT scheme. Last
Commit was added and total difficulty was removed. - 5: Updated to introduce a world model. No structural changes were made to blocks. This is used as a marker indicating when the data model should be migrated.
Declaration
public int ProtocolVersion { get; }
Property Value
Type | Description |
---|---|
System. |
See Also
| Improve this Doc View SourcePublicKey
The public key of the Miner. This is used for verifying the signature.
Although this is nullable type-wise, it is mandatory where
Protocol
Declaration
public PublicKey PublicKey { get; }
Property Value
Type | Description |
---|---|
Public |
Signature
The digital signature of the whole block content (except for
Hash, which is derived from the signature and other
contents). This is made by the Miner's
Private
As the block signature is introduced since
Signature
Declaration
public ImmutableArray<byte>? Signature { get; }
Property Value
Type | Description |
---|---|
System. |
StateRootHash
The
Declaration
public HashDigest<SHA256> StateRootHash { get; }
Property Value
Type | Description |
---|---|
Hash |
Timestamp
The time the block is created.
Declaration
public DateTimeOffset Timestamp { get; }
Property Value
Type | Description |
---|---|
Date |
Remarks
This is always UTC.
Transactions
Transactions belonging to the block.
Declaration
public IReadOnlyList<Transaction> Transactions { get; }
Property Value
Type | Description |
---|---|
IRead |
TxHash
The hash of all transactions in the block. This is null if the block has no transactions.
Declaration
public HashDigest<SHA256>? TxHash { get; }
Property Value
Type | Description |
---|---|
System. |
Methods
| Improve this Doc View SourceEquals(Block)
The complete block including all block contents and action evaluation.
Declaration
public bool Equals(Block other)
Parameters
Type | Name | Description |
---|---|---|
Block | other |
Returns
Type | Description |
---|---|
System. |
Equals(Nullable<Object>)
The complete block including all block contents and action evaluation.
Declaration
public override bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
System. |
obj |
Returns
Type | Description |
---|---|
System. |
GetHashCode()
The complete block including all block contents and action evaluation.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System. |
ToString()
The complete block including all block contents and action evaluation.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System. |
Operators
| Improve this Doc View SourceEquality(Block, Block)
Equivalent to
Declaration
public static bool operator ==(Block left, Block right)
Parameters
Returns
Type | Description |
---|---|
System. |
true if two blocks are equal. Otherwise false. |
Inequality(Block, Block)
Negation of
Declaration
public static bool operator !=(Block left, Block right)
Parameters
Returns
Type | Description |
---|---|
System. |
true if two blocks are different. Otherwise false. |
Explicit Interface Implementations
| Improve this Doc View SourceIBlockContent.Transactions
Transactions belonging to the block.
Declaration
IReadOnlyList<ITransaction> IBlockContent.Transactions { get; }
Returns
Type | Description |
---|---|
IRead |