Show / Hide Table of Contents

Class PreEvaluationBlock

A block candidate without evaluating actions (in its Transactions and a possible ) and state root hash.

Inheritance
Object
PreEvaluationBlock
Implements
IPreEvaluationBlock
IBlockContent
IPreEvaluationBlockHeader
IBlockMetadata
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
System.Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
System.Object.ToString()
Namespace: Libplanet.Types.Blocks
Assembly: Libplanet.Types.dll
Syntax
public sealed class PreEvaluationBlock : IPreEvaluationBlock, IBlockContent, IPreEvaluationBlockHeader, IBlockMetadata

Constructors

| Improve this Doc View Source

PreEvaluationBlock(IPreEvaluationBlockHeader, IEnumerable<Transaction>)

A block candidate without evaluating actions (in its Transactions and a possible ) and state root hash.

Declaration
public PreEvaluationBlock(IPreEvaluationBlockHeader preEvaluationBlockHeader, IEnumerable<Transaction> transactions)
Parameters
Type Name Description
IPreEvaluationBlockHeader preEvaluationBlockHeader
IEnumerable<Transaction> transactions

Properties

| Improve this Doc View Source

Header

Internal PreEvaluationBlockHeader.

Declaration
public PreEvaluationBlockHeader Header { get; }
Property Value
Type Description
PreEvaluationBlockHeader
| Improve this Doc View Source

Index

The height of the block.

Declaration
public long Index { get; }
Property Value
Type Description
System.Int64
Remarks

Zero means it is a genesis block. Not allowed to be negative.

| Improve this Doc View Source

LastCommit

The BlockCommit about previous block's vote information.

Declaration
public BlockCommit LastCommit { get; }
Property Value
Type Description
BlockCommit
| Improve this Doc View Source

Miner

The address of the miner.

Declaration
public Address Miner { get; }
Property Value
Type Description
Address
| Improve this Doc View Source

PreEvaluationHash

The hash derived from the block except of its state root hash (i.e., without action evaluation). Used for validating Nonce.

Declaration
public HashDigest<SHA256> PreEvaluationHash { get; }
Property Value
Type Description
HashDigest<SHA256>
See Also
Nonce
| Improve this Doc View Source

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
Nullable<BlockHash>
| Improve this Doc View Source

ProtocolVersion

The protocol version number. For the latest protocol version, see CurrentProtocolVersion. We have the following version info:

  • 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 PreEvaluationHash was added.
  • 2: Updated to include Signature to blocks. As a result, the miner's identity is provided as a PublicKey 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. LastCommit 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
Int32
See Also
CurrentProtocolVersion
| Improve this Doc View Source

PublicKey

The public key of the Miner. This is used for verifying the signature.

Although this is nullable type-wise, it is mandatory where ProtocolVersion is 2 or later. As blocks had not been signed in the previous protocol versions, the type of this is nullable.

Declaration
public PublicKey PublicKey { get; }
Property Value
Type Description
PublicKey
| Improve this Doc View Source

Timestamp

The time the block is created.

Declaration
public DateTimeOffset Timestamp { get; }
Property Value
Type Description
DateTimeOffset
Remarks

This is always UTC.

| Improve this Doc View Source

Transactions

Transactions belonging to the block.

Declaration
public IReadOnlyList<Transaction> Transactions { get; }
Property Value
Type Description
IReadOnlyList<Transaction>
| Improve this Doc View Source

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
Nullable<HashDigest<SHA256>>

Methods

| Improve this Doc View Source

Sign(PrivateKey, HashDigest<SHA256>)

Signs the block content with the given stateRootHash.

Declaration
public Block Sign(PrivateKey privateKey, HashDigest<SHA256> stateRootHash)
Parameters
Type Name Description
PrivateKey privateKey

The miner's private key to be used for signing the block. This must match to the block's Miner and PublicKey.

HashDigest<SHA256> stateRootHash

The state root hash to include to the input message to sign.

Returns
Type Description
Block

The signed block with the stateRootHash.

Remarks

As blocks have their signatures since the ProtocolVersion 2, it is not usable with blocks of the earlier ProtocolVersions than 2. To create a Block instance with ProtocolVersion less than 2, use Block's constructors with null signatures.

Exceptions
Type Condition
InvalidOperationException

Thrown when the block's ProtocolVersion is less than 2.

ArgumentException

Thrown when the given privateKey does not match to the block miner's PublicKey.

Explicit Interface Implementations

| Improve this Doc View Source

IBlockContent.Transactions

Transactions belonging to the block.

Declaration
IReadOnlyList<ITransaction> IBlockContent.Transactions { get; }
Returns
Type Description
IReadOnlyList<ITransaction>

Implements

IPreEvaluationBlock
IBlockContent
IPreEvaluationBlockHeader
IBlockMetadata

Extension Methods

IBlockMetadataExtensions.ValidateTimestamp(IBlockMetadata)
IBlockMetadataExtensions.ValidateTimestamp(IBlockMetadata, DateTimeOffset)
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium