Struct BlockDigest
Class that store uses to save blocks. This contains: BlockHeader, and list of TxIds.
Namespace: Libplanet.Store
Assembly: Libplanet.dll
Syntax
public readonly struct BlockDigest : IBlockMetadata, IBlockExcerpt
Constructors
| Improve this Doc View SourceBlockDigest(Bencodex.Types.Dictionary)
Creates BlockDigest instance from
Declaration
public BlockDigest(Bencodex.Types.Dictionary dict)
Parameters
| Type | Name | Description |
|---|---|---|
| Bencodex.Types.Dictionary | dict |
BlockDigest(BlockHeader, ImmutableArray<ImmutableArray<Byte>>)
Creates BlockDigest instance from BlockHeader and Transaction<T> ids the Block<T> has.
Declaration
public BlockDigest(BlockHeader header, ImmutableArray<ImmutableArray<byte>> txIds)
Parameters
| Type | Name | Description |
|---|---|---|
| BlockHeader | header | BlockHeader of the Block<T>. |
| ImmutableArray<ImmutableArray<Byte>> | txIds | Transaction<T> ids the Block<T> has. |
Properties
| Improve this Doc View SourceDifficulty
The mining difficulty that the block's Nonce has to satisfy.
Declaration
public readonly long Difficulty { get; }
Property Value
| Type | Description |
|---|---|
| Int64 |
Hash
The block hash.
Declaration
public readonly BlockHash Hash { get; }
Property Value
| Type | Description |
|---|---|
| BlockHash |
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. Disallowed to be negative.
See Also
| Improve this Doc View SourceMiner
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 should be null.
Declaration
public readonly BlockHash? PreviousHash { get; }
Property Value
| Type | Description |
|---|---|
| Nullable<BlockHash> |
ProtocolVersion
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 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 |
Signature
The block signature.
Declaration
public readonly ImmutableArray<byte>? Signature { get; }
Property Value
| Type | Description |
|---|---|
| Nullable<ImmutableArray<Byte>> |
StateRootHash
The state root hash.
Declaration
public readonly HashDigest<SHA256> StateRootHash { get; }
Property Value
| Type | Description |
|---|---|
| HashDigest<SHA256> |
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.
TotalDifficulty
The total mining difficulty since the genesis including the block's Difficulty.
Declaration
public readonly BigInteger TotalDifficulty { get; }
Property Value
| Type | Description |
|---|---|
| BigInteger |
Remarks
This must be greater than or equal to Difficulty at least, and must not be negative.
See Also
| Improve this Doc View SourceTxHash
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<HashDigest<SHA256>> |
TxIds
Declaration
public readonly ImmutableArray<ImmutableArray<byte>> TxIds { get; }
Property Value
| Type | Description |
|---|---|
| ImmutableArray<ImmutableArray<Byte>> |
Methods
| Improve this Doc View SourceDeserialize(Byte[])
Gets BlockDigest instance from serialized bytes.
Declaration
public static BlockDigest Deserialize(byte[] bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | bytes | Serialized BlockDigest. |
Returns
| Type | Description |
|---|---|
| BlockDigest | Deserialized BlockDigest. |
FromBlock<T>(Block<T>)
Gets BlockDigest representation of the Block<T>.
Declaration
public static BlockDigest FromBlock<T>(Block<T> block)
where T : IAction, new()
Parameters
| Type | Name | Description |
|---|---|---|
| Block<T> | block | The block instance to get its digest. |
Returns
| Type | Description |
|---|---|
| BlockDigest | BlockDigest representation of the Block<T>. |
Type Parameters
| Name | Description |
|---|---|
| T | An action type. |
GetHeader(HashAlgorithmGetter)
Gets the block header.
Declaration
public readonly BlockHeader GetHeader(HashAlgorithmGetter hashAlgorithmGetter)
Parameters
| Type | Name | Description |
|---|---|---|
| HashAlgorithmGetter | hashAlgorithmGetter | The function to determine hash algorithm used for proof-of-work mining. |
Returns
| Type | Description |
|---|---|
| BlockHeader | The block header. |
Serialize()
Gets serialized byte array of the BlockDigest.
Declaration
public readonly byte[] Serialize()
Returns
| Type | Description |
|---|---|
| Byte[] | Serialized byte array of BlockDigest. |
ToBencodex()
Gets
Declaration
public readonly Bencodex.Types.Dictionary ToBencodex()
Returns
| Type | Description |
|---|---|
| Bencodex.Types.Dictionary |