Show / Hide Table of Contents

Class BlockMetadata

A block metadata without transactions or any proof hash. This represents metadata of a block that is not yet mined nor proven.

To represent a block content including its metadata and transactions, use BlockContent.

Inheritance
System.Object
BlockMetadata
Implements
IBlockMetadata
Namespace: Libplanet.Types.Blocks
Assembly: Libplanet.Types.dll
Syntax
public class BlockMetadata : object, IBlockMetadata

Constructors

| Improve this Doc View Source

BlockMetadata(IBlockMetadata)

Creates a BlockMetadata by copying the fields of another block metadata.

Declaration
public BlockMetadata(IBlockMetadata metadata)
Parameters
Type Name Description
IBlockMetadata metadata

The source block metadata to copy. This needn't be an actual BlockMetadata instance, but can be any object which implements IBlockMetadata.

Remarks

As metadata needn't be an actual BlockMetadata instance, but simply any object implementing IBlockMetadata interface, it can't be trusted to satisfy all the constraints for a valid BlockMetadata instance. As such, conditions are checked again whilst creating a copy. This is a relatively heavy operation, so must be used sparingly.

This gets redirected to . Refer to the aforementioned constructor to see the full list of s that may be thrown.

See Also
BlockMetadata(Int32, Int64, DateTimeOffset, Address, PublicKey, Nullable<BlockHash>, Nullable<HashDigest<SHA256>>, BlockCommit, Nullable<HashDigest<SHA256>>)
| Improve this Doc View Source

BlockMetadata(Int32, Int64, DateTimeOffset, Address, PublicKey, Nullable<BlockHash>, Nullable<HashDigest<SHA256>>, BlockCommit, Nullable<HashDigest<SHA256>>)

Creates a BlockMetadata by manually filling in the fields for BlockMetadata. All other public constructors are redirected to this one.

Declaration
public BlockMetadata(int protocolVersion, long index, DateTimeOffset timestamp, Address miner, PublicKey publicKey, BlockHash? previousHash, HashDigest<SHA256>? txHash, BlockCommit lastCommit, HashDigest<SHA256>? evidenceHash)
Parameters
Type Name Description
System.Int32 protocolVersion

Goes to ProtocolVersion.

System.Int64 index

Goes to Index.

DateTimeOffset timestamp

Goes to Timestamp.

Address miner

Goes to Miner.

PublicKey publicKey

Goes to PublicKey.

System.Nullable<BlockHash> previousHash

Goes to PreviousHash.

System.Nullable<HashDigest<SHA256>> txHash

Goes to TxHash.

BlockCommit lastCommit

Goes to LastCommit.

System.Nullable<HashDigest<SHA256>> evidenceHash

Goes to EvidenceHash.

Remarks

Except for debugging and/or testing purposes, this shouldn't be called directly.

Exceptions
Type Condition
InvalidBlockProtocolVersionException

Thrown when protocolVersion is less than zero or greater than CurrentProtocolVersion, the latest known protocol version.

InvalidBlockIndexException

Thrown when index is less than zero.

InvalidBlockPublicKeyException

Thrown when any of the following conditions isn't satisfied:

  • If protocolVersion >= 2, miner should match the derived address of publicKey.
  • Otherwise, publicKey must be null.
InvalidBlockPreviousHashException

Thrown when previousHash is not null while index is zero or previousHash is null while index is nonzero.

See Also
BlockContent
| Improve this Doc View Source

BlockMetadata(Int64, DateTimeOffset, PublicKey, Nullable<BlockHash>, Nullable<HashDigest<SHA256>>, BlockCommit, Nullable<HashDigest<SHA256>>)

Creates a BlockMetadata with CurrentProtocolVersion as its ProtocolVersion.

Declaration
public BlockMetadata(long index, DateTimeOffset timestamp, PublicKey publicKey, BlockHash? previousHash, HashDigest<SHA256>? txHash, BlockCommit lastCommit, HashDigest<SHA256>? evidenceHash)
Parameters
Type Name Description
System.Int64 index

Goes to Index.

DateTimeOffset timestamp

Goes to Timestamp.

PublicKey publicKey

Goes to PublicKey.

System.Nullable<BlockHash> previousHash

Goes to PreviousHash.

System.Nullable<HashDigest<SHA256>> txHash

Goes to TxHash.

BlockCommit lastCommit

Goes to LastCommit.

System.Nullable<HashDigest<SHA256>> evidenceHash

Goes to EvidenceHash.

See Also
BlockMetadata(Int32, Int64, DateTimeOffset, Address, PublicKey, Nullable<BlockHash>, Nullable<HashDigest<SHA256>>, BlockCommit, Nullable<HashDigest<SHA256>>)

Fields

| Improve this Doc View Source

CurrencyAccountProtocolVersion

The starting protocol version where fungible assets are stored in resepctive currency accounts instead of the legacy account. Prior to this version, all fungible assets are stored in the legacy account. Moreover, starting with this version, every total supply of each currency is trackable regardless of TotalSupplyTrackable.

Declaration
public const int CurrencyAccountProtocolVersion = null
Field Value
Type Description
System.Int32
See Also
BlockContent
| Improve this Doc View Source

CurrentProtocolVersion

The latest protocol version.

Declaration
public const int CurrentProtocolVersion = null
Field Value
Type Description
System.Int32
See Also
BlockContent
| Improve this Doc View Source

EvidenceProtocolVersion

The starting protocol version where evidence of the consensus process is detected and stored. In the consensus process, evidence of double signing is stored, and in the application layer, you can define and use custom evidence.

Declaration
public const int EvidenceProtocolVersion = null
Field Value
Type Description
System.Int32
See Also
BlockContent
| Improve this Doc View Source

PBFTProtocolVersion

The starting protocol version where PBFT validation is used instead of PoW validation. Prior to this version, PoW validation is used.

Declaration
public const int PBFTProtocolVersion = null
Field Value
Type Description
System.Int32
See Also
BlockContent
| Improve this Doc View Source

SignatureProtocolVersion

The starting protocol version where Signature was added. Prior to this version, Blocks had no signature.

In its serialized form, Miner was removed and PublicKey together with Signature were added.

Declaration
public const int SignatureProtocolVersion = null
Field Value
Type Description
System.Int32
See Also
BlockContent
| Improve this Doc View Source

SlothProtocolVersion

The starting protocol version where StateRootHash is postponed by one blocks. Meaning of StateRootHash has been changed from the result state reference of Transactions to state reference before Transactions were executed.

Declaration
public const int SlothProtocolVersion = null
Field Value
Type Description
System.Int32
See Also
BlockContent
| Improve this Doc View Source

TransactionOrderingFixProtocolVersion

The starting protocol version where a more secure Transaction shuffling scheme is used.

Declaration
public const int TransactionOrderingFixProtocolVersion = null
Field Value
Type Description
System.Int32
See Also
BlockContent
| Improve this Doc View Source

TransferFixProtocolVersion

The starting protocol version where a bug in transferring asset was fixed. Prior to this version, it was possible to duplicate FungibleAssetValue.

Also, ProtocolVersion was added.

Declaration
public const int TransferFixProtocolVersion = null
Field Value
Type Description
System.Int32
See Also
BlockContent
| Improve this Doc View Source

ValidatorSetAccountProtocolVersion

The starting protocol version where the validator set is stored in a separate account instead of the legacy account. Prior to this version, the validator set is stored in the legacy account.

Declaration
public const int ValidatorSetAccountProtocolVersion = null
Field Value
Type Description
System.Int32
See Also
BlockContent
| Improve this Doc View Source

WorldStateProtocolVersion

The starting protocol version where the world state model is used instead of the legacy state model. Prior to this version, the legacy state model is used.

Declaration
public const int WorldStateProtocolVersion = null
Field Value
Type Description
System.Int32
See Also
BlockContent

Properties

| Improve this Doc View Source

EvidenceHash

A block metadata without transactions or any proof hash. This represents metadata of a block that is not yet mined nor proven.

To represent a block content including its metadata and transactions, use BlockContent.

Declaration
public HashDigest<SHA256>? EvidenceHash { get; }
Property Value
Type Description
System.Nullable<HashDigest<SHA256>>
See Also
BlockContent
| 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.

See Also
BlockContent
| Improve this Doc View Source

LastCommit

A block metadata without transactions or any proof hash. This represents metadata of a block that is not yet mined nor proven.

To represent a block content including its metadata and transactions, use BlockContent.

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

Miner

The address of the miner.

Declaration
public Address Miner { get; }
Property Value
Type Description
Address
See Also
BlockContent
| 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
System.Nullable<BlockHash>
See Also
BlockContent
| 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
System.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
See Also
BlockContent
| 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.

See Also
BlockContent
| 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
System.Nullable<HashDigest<SHA256>>
See Also
BlockContent

Methods

| Improve this Doc View Source

DerivePreEvaluationHash()

Derives a hash digest from the block metadata.

Declaration
public HashDigest<SHA256> DerivePreEvaluationHash()
Returns
Type Description
HashDigest<SHA256>

A pre-evaluation block hash.

See Also
BlockContent
| Improve this Doc View Source

MakeCandidateData()

Serializes data of a possible candidate shifted from it into a Bencodex dictionary.

Declaration
public Bencodex.Types.Dictionary MakeCandidateData()
Returns
Type Description
Bencodex.Types.Dictionary

The serialized block content in a Bencodex dictionary.

See Also
BlockContent

Implements

IBlockMetadata

See Also

BlockContent
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium