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
Implements
Namespace: Libplanet.Types.Blocks
Assembly: Libplanet.Types.dll
Syntax
public class BlockMetadata : object, IBlockMetadata
Constructors
| Improve this Doc View SourceBlockMetadata(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
See Also
| Improve this Doc View SourceBlockMetadata(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
|
InvalidBlockIndexException | Thrown when |
InvalidBlockPublicKeyException | Thrown when any of the following conditions isn't satisfied:
|
InvalidBlockPreviousHashException | Thrown when
|
See Also
| Improve this Doc View SourceBlockMetadata(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
Fields
| Improve this Doc View SourceCurrencyAccountProtocolVersion
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
| Improve this Doc View SourceCurrentProtocolVersion
The latest protocol version.
Declaration
public const int CurrentProtocolVersion = null
Field Value
Type | Description |
---|---|
System.Int32 |
See Also
| Improve this Doc View SourceEvidenceProtocolVersion
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
| Improve this Doc View SourcePBFTProtocolVersion
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
| Improve this Doc View SourceSignatureProtocolVersion
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
| Improve this Doc View SourceSlothProtocolVersion
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
| Improve this Doc View SourceTransactionOrderingFixProtocolVersion
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
| Improve this Doc View SourceTransferFixProtocolVersion
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
| Improve this Doc View SourceValidatorSetAccountProtocolVersion
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
| Improve this Doc View SourceWorldStateProtocolVersion
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
Properties
| Improve this Doc View SourceEvidenceHash
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
| Improve this Doc View SourceIndex
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
| Improve this Doc View SourceLastCommit
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
| Improve this Doc View SourceMiner
The address of the miner.
Declaration
public Address Miner { get; }
Property Value
Type | Description |
---|---|
Address |
See Also
| Improve this Doc View SourcePreviousHash
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
| Improve this Doc View SourceProtocolVersion
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
| 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 PublicKey PublicKey { get; }
Property Value
Type | Description |
---|---|
PublicKey |
See Also
| Improve this Doc View SourceTimestamp
The time the block is created.
Declaration
public DateTimeOffset Timestamp { get; }
Property Value
Type | Description |
---|---|
DateTimeOffset |
Remarks
This is always UTC.
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 HashDigest<SHA256>? TxHash { get; }
Property Value
Type | Description |
---|---|
System.Nullable<HashDigest<SHA256>> |
See Also
Methods
| Improve this Doc View SourceDerivePreEvaluationHash()
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
| Improve this Doc View SourceMakeCandidateData()
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. |