Struct BlockDigest
Class that store uses to save blocks. This contains:
Block
Inherited Members
Namespace: Libplanet.Store
Assembly: Libplanet.dll
Syntax
public readonly struct BlockDigest : IBlockMetadata, IBlockExcerpt
Constructors
| Improve this Doc View SourceBlockDigest(Dictionary)
Creates Block
Declaration
public BlockDigest(Dictionary dict)
Parameters
Type | Name | Description |
---|---|---|
Bencodex. |
dict | Bencodex. |
BlockDigest(BlockHeader, ImmutableArray<ImmutableArray<Byte>>)
Creates Block
Declaration
public BlockDigest(BlockHeader header, ImmutableArray<ImmutableArray<byte>> txIds)
Parameters
Type | Name | Description |
---|---|---|
Block |
header | Block |
Immutable |
txIds | Transaction ids the Block has. |
Properties
| Improve this Doc View SourceHash
The block hash.
Declaration
public readonly BlockHash Hash { get; }
Property Value
Type | Description |
---|---|
Block |
Index
The height of the block.
Declaration
public readonly long Index { get; }
Property Value
Type | Description |
---|---|
Int64 |
Remarks
Zero means it is a genesis block. Not allowed to be negative.
See Also
| Improve this Doc View SourceLastCommit
The Block
Declaration
public readonly BlockCommit LastCommit { get; }
Property Value
Type | Description |
---|---|
Block |
Miner
The address of the miner.
Declaration
public readonly Address Miner { get; }
Property Value
Type | Description |
---|---|
Address |
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
| Improve this Doc View SourceProtocolVersion
The protocol version number.
Declaration
public readonly int ProtocolVersion { get; }
Property Value
Type | Description |
---|---|
Int32 |
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 readonly PublicKey PublicKey { get; }
Property Value
Type | Description |
---|---|
Public |
Signature
The block signature.
Declaration
public readonly ImmutableArray<byte>? Signature { get; }
Property Value
Type | Description |
---|---|
Nullable<Immutable |
StateRootHash
The state root hash.
Declaration
public readonly HashDigest<SHA256> StateRootHash { get; }
Property Value
Type | Description |
---|---|
Hash |
Timestamp
The time the block is created.
Declaration
public readonly DateTimeOffset Timestamp { get; }
Property Value
Type | Description |
---|---|
Date |
Remarks
This is always UTC.
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 |
---|---|
Nullable<Hash |
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 |
---|---|
Immutable |
Methods
| Improve this Doc View SourceDeserialize(Byte[])
Gets Blockbytes
.
Declaration
public static BlockDigest Deserialize(byte[] bytes)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | bytes | Serialized Block |
Returns
Type | Description |
---|---|
Block |
Deserialized Block |
Exceptions
Type | Condition |
---|---|
Argument |
Thrown when the passed |
Bencodex. |
Thrown when decoded value is not
Bencodex. |
FromBlock(Block)
Gets Block
Declaration
public static BlockDigest FromBlock(Block block)
Parameters
Type | Name | Description |
---|---|---|
Block | block | The block instance to get its digest. |
Returns
Type | Description |
---|---|
Block |
Block |
GetHeader()
Gets the block header.
Declaration
public readonly BlockHeader GetHeader()
Returns
Type | Description |
---|---|
Block |
The block header. |
Serialize()
Gets serialized byte array of the Block
Declaration
public readonly byte[] Serialize()
Returns
Type | Description |
---|---|
Byte[] | Serialized byte array of Block |
ToBencodex()
Gets Bencodex.
Declaration
public readonly Dictionary ToBencodex()
Returns
Type | Description |
---|---|
Bencodex. |
Bencodex. |