Show / Hide Table of Contents

Struct BlockDigest

Class that store uses to save blocks. This contains: BlockHeader, and list of TxIds.

Implements
IBlockMetadata
IBlockExcerpt
Namespace: Libplanet.Store
Assembly: Libplanet.Store.dll
Syntax
public readonly struct BlockDigest : IBlockMetadata, IBlockExcerpt

Constructors

| Improve this Doc View Source

BlockDigest(Bencodex.Types.Dictionary)

Creates BlockDigest instance from representation of the Block.

Declaration
public BlockDigest(Bencodex.Types.Dictionary dict)
Parameters
Type Name Description
Bencodex.Types.Dictionary dict

representation of the Block.

| Improve this Doc View Source

BlockDigest(BlockHeader, ImmutableArray<ImmutableArray<Byte>>, ImmutableArray<ImmutableArray<Byte>>)

Creates BlockDigest instance from BlockHeader and Transaction ids the Block has.

Declaration
public BlockDigest(BlockHeader header, ImmutableArray<ImmutableArray<byte>> txIds, ImmutableArray<ImmutableArray<byte>> evidenceIds)
Parameters
Type Name Description
BlockHeader header

BlockHeader of the Block.

ImmutableArray<ImmutableArray<System.Byte>> txIds

Transaction ids the Block has.

ImmutableArray<ImmutableArray<System.Byte>> evidenceIds

EvidenceBase ids the Block has.

Properties

| Improve this Doc View Source

EvidenceHash

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

Declaration
public readonly HashDigest<SHA256>? EvidenceHash { get; }
Property Value
Type Description
System.Nullable<HashDigest<SHA256>>
| Improve this Doc View Source

EvidenceIds

The s of EvidenceBases in a Block. This is not necessarily ordered by .

Declaration
public readonly ImmutableArray<ImmutableArray<byte>> EvidenceIds { get; }
Property Value
Type Description
ImmutableArray<ImmutableArray<System.Byte>>
| Improve this Doc View Source

Hash

The block hash.

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

Index

The height of the block.

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

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

See Also
Index
| Improve this Doc View Source

LastCommit

The BlockCommit about previous block's vote information.

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

Miner

The address of the miner.

Declaration
public readonly Address Miner { get; }
Property Value
Type Description
Address
| 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 readonly BlockHash? PreviousHash { get; }
Property Value
Type Description
System.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 readonly 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 readonly PublicKey PublicKey { get; }
Property Value
Type Description
PublicKey
| Improve this Doc View Source

Signature

The block signature.

Declaration
public readonly ImmutableArray<byte>? Signature { get; }
Property Value
Type Description
System.Nullable<ImmutableArray<System.Byte>>
| Improve this Doc View Source

StateRootHash

The state root hash.

Declaration
public readonly HashDigest<SHA256> StateRootHash { get; }
Property Value
Type Description
HashDigest<SHA256>
| Improve this Doc View Source

Timestamp

The time the block is created.

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

This is always UTC.

| 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 readonly HashDigest<SHA256>? TxHash { get; }
Property Value
Type Description
System.Nullable<HashDigest<SHA256>>
| Improve this Doc View Source

TxIds

The Ids of Transactions in a Block. This is not necessarily ordered by Id.

Declaration
public readonly ImmutableArray<ImmutableArray<byte>> TxIds { get; }
Property Value
Type Description
ImmutableArray<ImmutableArray<System.Byte>>

Methods

| Improve this Doc View Source

Deserialize(Byte[])

Gets BlockDigest instance from serialized bytes.

Declaration
public static BlockDigest Deserialize(byte[] bytes)
Parameters
Type Name Description
System.Byte[] bytes

Serialized BlockDigest.

Returns
Type Description
BlockDigest

Deserialized BlockDigest.

| Improve this Doc View Source

FromBlock(Block)

Gets BlockDigest representation of the Block.

Declaration
public static BlockDigest FromBlock(Block block)
Parameters
Type Name Description
Block block

The block instance to get its digest.

Returns
Type Description
BlockDigest

BlockDigest representation of the Block.

| Improve this Doc View Source

GetHeader()

Gets the block header.

Declaration
public readonly BlockHeader GetHeader()
Returns
Type Description
BlockHeader

The block header.

| Improve this Doc View Source

Serialize()

Gets serialized byte array of the BlockDigest.

Declaration
public readonly byte[] Serialize()
Returns
Type Description
System.Byte[]

Serialized byte array of BlockDigest.

| Improve this Doc View Source

ToBencodex()

Gets representation of BlockDigest.

Declaration
public readonly Bencodex.Types.Dictionary ToBencodex()
Returns
Type Description
Bencodex.Types.Dictionary

representation of BlockDigest.

Implements

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