Show / Hide Table of Contents

Class BlockContent

A block content without any proofs like nonce or hash. This represents contents of a block that is not yet mined.

Inheritance
System.Object
BlockContent
Implements
IBlockContent
IBlockMetadata
Namespace: Libplanet.Types.Blocks
Assembly: Libplanet.Types.dll
Syntax
public sealed class BlockContent : object, IBlockContent, IBlockMetadata
Remarks

Unlike other model types like Block or Transaction, this type is mutable.

Constructors

| Improve this Doc View Source

BlockContent(BlockMetadata, IEnumerable<Transaction>, IEnumerable<EvidenceBase>)

Creates a new BlockContent instance with given metadata and transactions.

Declaration
public BlockContent(BlockMetadata metadata, IEnumerable<Transaction> transactions, IEnumerable<EvidenceBase> evidence)
Parameters
Type Name Description
BlockMetadata metadata

The BlockMetadata to include in the block.

IEnumerable<Transaction> transactions

The transactions to include in the block.

IEnumerable<EvidenceBase> evidence

The evidence to include in the block.

Remarks

Unlike other model types like Block or Transaction, this type is mutable.

Exceptions
Type Condition
InvalidBlockTxHashException

Thrown when the given metadata's TxHash is inconsistent with transactions.

InvalidTxSignatureException

Thrown when any tx signature is invalid or not signed by its signer.

InvalidTxNonceException

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 .

InvalidTxGenesisHashException

Thrown when transactions to set have inconsistent genesis hashes.

| Improve this Doc View Source

BlockContent(BlockMetadata)

Creates a new BlockContent instance with given metadata and without any Transactions.

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

The BlockMetadata to include in the block.

Remarks

Unlike other model types like Block or Transaction, this type is mutable.

Exceptions
Type Condition
InvalidBlockTxHashException

Thrown when the given metadata's TxHash is not .

| Improve this Doc View Source

BlockContent(IBlockMetadata, IEnumerable<Transaction>, IEnumerable<EvidenceBase>)

Creates a new BlockContent instance filled with given metadata and transactions.

Declaration
public BlockContent(IBlockMetadata metadata, IEnumerable<Transaction> transactions, IEnumerable<EvidenceBase> evidence)
Parameters
Type Name Description
IBlockMetadata metadata

The IBlockMetadata to copy.

IEnumerable<Transaction> transactions

The transactions to include in the block.

IEnumerable<EvidenceBase> evidence

The evidence to include in the block.

Remarks

This creates a new instance of BlockMetadata to check the validity of metadata, hence throws any s that may arise from a BlockMetadata's constructor in addition to the ones explicitly listed below.

Exceptions
Type Condition
InvalidTxSignatureException

Thrown when any tx signature is invalid or not signed by its signer.

InvalidTxNonceException

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 .

InvalidTxGenesisHashException

Thrown when transactions to set have inconsistent genesis hashes.

InvalidBlockTxHashException

Thrown when the given metadata's TxHash is inconsistent with transactions.

See Also
BlockMetadata

Properties

| Improve this Doc View Source

Evidence

Committing EvidenceIds of vote infraction that has been made on previous blocks.

Declaration
public IReadOnlyList<EvidenceBase> Evidence { get; }
Property Value
Type Description
IReadOnlyList<EvidenceBase>
Remarks

Unlike other model types like Block or Transaction, this type is mutable.

| Improve this Doc View Source

EvidenceHash

Committing EvidenceIds of vote infraction that has been made on previous blocks.

Declaration
public HashDigest<SHA256>? EvidenceHash { get; }
Property Value
Type Description
System.Nullable<HashDigest<SHA256>>
Remarks

Unlike other model types like Block or Transaction, this type is mutable.

| 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
Remarks

Unlike other model types like Block or Transaction, this type is mutable.

| Improve this Doc View Source

Metadata

Internal BlockMetadata.

Declaration
public BlockMetadata Metadata { get; }
Property Value
Type Description
BlockMetadata
Remarks

Unlike other model types like Block or Transaction, this type is mutable.

| Improve this Doc View Source

Miner

The address of the miner.

Declaration
public Address Miner { get; }
Property Value
Type Description
Address
Remarks

Unlike other model types like Block or Transaction, this type is mutable.

| 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>
Remarks

Unlike other model types like Block or Transaction, this type is mutable.

| 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
Remarks

Unlike other model types like Block or Transaction, this type is mutable.

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
Remarks

Unlike other model types like Block or Transaction, this type is mutable.

| 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>
Remarks

This is always ordered by Id.

| 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>>
Remarks

Unlike other model types like Block or Transaction, this type is mutable.

Methods

| Improve this Doc View Source

DeriveEvidenceHash(IEnumerable<EvidenceBase>)

A block content without any proofs like nonce or hash. This represents contents of a block that is not yet mined.

Declaration
public static HashDigest<SHA256>? DeriveEvidenceHash(IEnumerable<EvidenceBase> evidence)
Parameters
Type Name Description
IEnumerable<EvidenceBase> evidence
Returns
Type Description
System.Nullable<HashDigest<SHA256>>
Remarks

Unlike other model types like Block or Transaction, this type is mutable.

| Improve this Doc View Source

DeriveTxHash(IEnumerable<Transaction>)

Derives TxHash from given transactions.

Declaration
public static HashDigest<SHA256>? DeriveTxHash(IEnumerable<Transaction> transactions)
Parameters
Type Name Description
IEnumerable<Transaction> transactions

The transactions to derive TxHash from. This must be ordered by Id.

Returns
Type Description
System.Nullable<HashDigest<SHA256>>

The derived TxHash.

Remarks

Unlike other model types like Block or Transaction, this type is mutable.

| Improve this Doc View Source

Propose()

A block content without any proofs like nonce or hash. This represents contents of a block that is not yet mined.

Declaration
public PreEvaluationBlock Propose()
Returns
Type Description
PreEvaluationBlock
Remarks

Unlike other model types like Block or Transaction, this type is mutable.

Explicit Interface Implementations

| Improve this Doc View Source

IBlockContent.Transactions

A block content without any proofs like nonce or hash. This represents contents of a block that is not yet mined.

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

Unlike other model types like Block or Transaction, this type is mutable.

Implements

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