Class BlockContent<T>
A block content without any proofs like nonce or hash. This represents contents of a block that is not yet mined.
Inherited Members
Namespace: Libplanet.Blocks
Assembly: Libplanet.dll
Syntax
public sealed class BlockContent<T> : BlockMetadata, IBlockContent<T>, IBlockMetadata where T : IAction, new()
Type Parameters
Name | Description |
---|---|
T | A class implementing IAction to include. This type parameter is aligned with Transaction<T>'s type parameter. |
Remarks
Unlike other model types like Block<T> or Transaction<T>, this type is mutable. To get a distinct instance with partly changed fields, use BlockContent(IBlockContent<T>) constructor and property setters on a copy instead.
Constructors
| Improve this Doc View SourceBlockContent()
Creates a new empty BlockContent<T> instance.
Declaration
public BlockContent()
BlockContent(IBlockContent<T>)
Creates a BlockContent<T> by copying the fields of another block
content
.
Declaration
public BlockContent(IBlockContent<T> content)
Parameters
Type | Name | Description |
---|---|---|
IBlock |
content | This source of the block content to copy. This hasn't be a actual BlockContent<T> instance, but can be any object which implements IBlockContent<T> instance. |
Exceptions
Type | Condition |
---|---|
Invalid |
Thrown when
the |
Invalid |
Thrown when the value to set is negative. |
Invalid |
Thrown when the value to set is is negative. |
Invalid |
Thrown when
the |
Invalid |
Thrown when any tx signature is invalid or not signed by its signer. |
Invalid |
Thrown when any tx signer is not derived from its its public key. |
Invalid |
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 BlockChain<T>. |
Invalid |
Thrown when transactions to set have inconsistent genesis hashes. |
Invalid |
Thrown when the given block
|
BlockContent(IBlockMetadata)
Creates a new BlockContent<T> instance filled with the given
metadata
's contents and zero transactions.
Declaration
public BlockContent(IBlockMetadata metadata)
Parameters
Type | Name | Description |
---|---|---|
IBlock |
metadata | The IBlock |
Exceptions
Type | Condition |
---|---|
Invalid |
Thrown when
the |
Invalid |
Thrown when the value to set is negative. |
Invalid |
Thrown when the value to set is is negative. |
Invalid |
Thrown when
the |
Invalid |
Thrown when any tx signature is invalid or not signed by its signer. |
Invalid |
Thrown when any tx signer is not derived from its its public key. |
Invalid |
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 BlockChain<T>. |
Invalid |
Thrown when transactions to set have inconsistent genesis hashes. |
Invalid |
Thrown when the given
|
BlockContent(IBlockMetadata, IEnumerable<Transaction<T>>)
Creates a new BlockContent<T> instance filled with the given
metadata
's contents and transactions
.
Declaration
public BlockContent(IBlockMetadata metadata, IEnumerable<Transaction<T>> transactions)
Parameters
Type | Name | Description |
---|---|---|
IBlock |
metadata | The IBlock |
IEnumerable<Transaction<T>> | transactions | The transactions to include in the block. |
Exceptions
Type | Condition |
---|---|
Invalid |
Thrown when
the |
Invalid |
Thrown when the |
Invalid |
Thrown when
the |
Invalid |
Thrown when
the |
Invalid |
Thrown when any tx signature is invalid or not signed by its signer. |
Invalid |
Thrown when any tx signer is not derived from its its public key. |
Invalid |
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 BlockChain<T>. |
Invalid |
Thrown when transactions to set have inconsistent genesis hashes. |
Invalid |
Thrown when the given
|
Properties
| Improve this Doc View SourceTransactions
Transactions belonging to the block.
Declaration
public IReadOnlyList<Transaction<T>> Transactions { get; set; }
Property Value
Type | Description |
---|---|
IRead |
Remarks
This is always ordered by Id.
When Transactions is updated, Tx
Exceptions
Type | Condition |
---|---|
Invalid |
Thrown when any tx signature is invalid or not signed by its signer. |
Invalid |
Thrown when any tx signer is not derived from its its public key. |
Invalid |
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 BlockChain<T>. |
Invalid |
Thrown when transactions to set have inconsistent genesis hashes. |
TxHash
The hash of all transactions in the block. This is null
if the block has no
transactions.
Declaration
public override HashDigest<SHA256>? TxHash { get; set; }
Property Value
Type | Description |
---|---|
Nullable<Hash |
Overrides
Exceptions
Type | Condition |
---|---|
Invalid |
Thrown when the Tx |
Methods
| Improve this Doc View SourceMine(HashAlgorithmType, CancellationToken)
Mines the PoW (proof-of-work) nonce satisfying the block Difficulty, and returns a valid PreEvaluationBlock<T> instance.
Declaration
public PreEvaluationBlock<T> Mine(HashAlgorithmType hashAlgorithm, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
Hash |
hashAlgorithm | The hash algorithm to use for calculating pre-evaluation hash. |
Cancellation |
cancellationToken | An optional cancellation token used to propagate signal that this operation should be cancelled. |
Returns
Type | Description |
---|---|
Pre |
A PreEvaluationBlock<T> instance with a valid proof-of-work. |