Class PreEvaluationBlock<T>
A block candidate without evaluating actions (in its Transactions and a possible BlockAction) and state root hash.
Inherited Members
Namespace: Libplanet.Blocks
Assembly: Libplanet.dll
Syntax
public sealed class PreEvaluationBlock<T> : PreEvaluationBlockHeader, IPreEvaluationBlock<T>, IBlockContent<T>, IPreEvaluationBlockHeader, 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
It guarantees that every instance of this type has a valid proof-of-work Nonce which satisfies its Difficulty.
Constructors
| Improve this Doc View SourcePreEvaluationBlock(IBlockContent<T>, HashAlgorithmType, Nonce)
Creates a PreEvaluationBlock<T> instance with its
content
data and a valid proof-of-work nonce
which satisfies the required Difficulty.
Declaration
public PreEvaluationBlock(IBlockContent<T> content, HashAlgorithmType hashAlgorithm, Nonce nonce)
Parameters
Type | Name | Description |
---|---|---|
IBlockContent<T> | content | Block's content data. |
HashAlgorithmType | hashAlgorithm | The hash algorithm used for calculating PreEvaluationHash. |
Nonce | nonce | A valid proof-of-work nonce which satisfies the required Difficulty. |
Remarks
PreEvaluationHash is automatically derived from the given arguments.
Exceptions
Type | Condition |
---|---|
InvalidBlockProtocolVersionException | Thrown when
the |
InvalidBlockIndexException | Thrown when the value to set is negative. |
InvalidBlockDifficultyException | Thrown when the value to set is is negative. |
InvalidBlockTotalDifficultyException | Thrown when
the |
InvalidTxSignatureException | Thrown when any tx signature is invalid or not signed by its signer. |
InvalidTxPublicKeyException | Thrown when any tx signer is not derived from its its public key. |
InvalidTxNonceException | 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>. |
InvalidTxGenesisHashException | Thrown when transactions to set have inconsistent genesis hashes. |
InvalidBlockTxHashException | Thrown when the given block
|
InvalidBlockNonceException | Thrown when the given proof-of-work
|
PreEvaluationBlock(IBlockContent<T>, HashAlgorithmType, Nonce, ImmutableArray<Byte>)
Creates a PreEvaluationBlock<T> instance with its
content
data, a valid proof-of-work nonce
which satisfies the required Difficulty,
and a preEvaluationHash
digest derived from them.
Declaration
public PreEvaluationBlock(IBlockContent<T> content, HashAlgorithmType hashAlgorithm, Nonce nonce, ImmutableArray<byte> preEvaluationHash)
Parameters
Type | Name | Description |
---|---|---|
IBlockContent<T> | content | Block's content data. |
HashAlgorithmType | hashAlgorithm | The hash algorithm used for calculating PreEvaluationHash. |
Nonce | nonce | A valid proof-of-work nonce which satisfies the required Difficulty. |
ImmutableArray<Byte> | preEvaluationHash | The hash digest of the |
Exceptions
Type | Condition |
---|---|
InvalidBlockProtocolVersionException | Thrown when
the |
InvalidBlockIndexException | Thrown when the value to set is negative. |
InvalidBlockDifficultyException | Thrown when the value to set is is negative. |
InvalidBlockTotalDifficultyException | Thrown when
the |
InvalidTxSignatureException | Thrown when any tx signature is invalid or not signed by its signer. |
InvalidTxPublicKeyException | Thrown when any tx signer is not derived from its its public key. |
InvalidTxNonceException | 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>. |
InvalidTxGenesisHashException | Thrown when transactions to set have inconsistent genesis hashes. |
InvalidBlockTxHashException | Thrown when the given block
|
InvalidBlockPreEvaluationHashException | Thrown when the given
|
InvalidBlockNonceException | Thrown when the given proof-of-work
|
Properties
| Improve this Doc View SourceTransactions
Transactions belonging to the block.
Declaration
public IReadOnlyList<Transaction<T>> Transactions { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<Transaction<T>> |
Remarks
This is always ordered by Id.
Methods
| Improve this Doc View SourceDetermineStateRootHash(IAction, IStateStore)
Evaluates all actions in the Transactions and
a blockAction
(if any), and determines
the StateRootHash from ground zero (i.e., empty state root).
Declaration
public HashDigest<SHA256> DetermineStateRootHash(IAction blockAction, IStateStore stateStore)
Parameters
Type | Name | Description |
---|---|---|
IAction | blockAction | An optional BlockAction. |
IStateStore | stateStore | The Libplanet.Blockchain.BlockChain`1.StateStore. |
Returns
Type | Description |
---|---|
HashDigest<SHA256> | The resulting StateRootHash. |
Remarks
This can be used with only genesis blocks. For blocks with indices greater than zero, use DetermineStateRootHash(BlockChain<T>) overloaded one instead.
DetermineStateRootHash(IAction, IStateStore, out IImmutableDictionary<String, IValue>)
Evaluates all actions in the Transactions and
a blockAction
(if any), and determines
the StateRootHash from ground zero (i.e., empty state root).
Declaration
public HashDigest<SHA256> DetermineStateRootHash(IAction blockAction, IStateStore stateStore, out IImmutableDictionary<string, IValue> statesDelta)
Parameters
Type | Name | Description |
---|---|---|
IAction | blockAction | An optional BlockAction. |
IStateStore | stateStore | The Libplanet.Blockchain.BlockChain`1.StateStore. |
IImmutableDictionary<String, IValue> | statesDelta | Returns made changes on states. |
Returns
Type | Description |
---|---|
HashDigest<SHA256> | The resulting StateRootHash. |
Remarks
This can be used with only genesis blocks. For blocks with indices greater than zero, use DetermineStateRootHash(BlockChain<T>) overloaded one instead.
DetermineStateRootHash(BlockChain<T>)
Evaluates all actions in the Transactions and an optional BlockAction, and determines the StateRootHash.
Declaration
public HashDigest<SHA256> DetermineStateRootHash(BlockChain<T> blockChain)
Parameters
Type | Name | Description |
---|---|---|
BlockChain<T> | blockChain | The blockchain on which actions are evaluated based. |
Returns
Type | Description |
---|---|
HashDigest<SHA256> | The resulting StateRootHash. |
DetermineStateRootHash(BlockChain<T>, StateCompleterSet<T>, out IImmutableDictionary<String, IValue>)
Evaluates all actions in the Transactions and an optional BlockAction, and determines the StateRootHash.
Declaration
public HashDigest<SHA256> DetermineStateRootHash(BlockChain<T> blockChain, StateCompleterSet<T> stateCompleterSet, out IImmutableDictionary<string, IValue> statesDelta)
Parameters
Type | Name | Description |
---|---|---|
BlockChain<T> | blockChain | The blockchain on which actions are evaluated based. |
StateCompleterSet<T> | stateCompleterSet | The StateCompleterSet<T> to use when it needs states unevaluated yet. |
IImmutableDictionary<String, IValue> | statesDelta | Returns made changes on states. |
Returns
Type | Description |
---|---|
HashDigest<SHA256> | The resulting StateRootHash. |
Evaluate(PrivateKey, IAction, IStateStore)
Evaluates all actions in the Transactions and
a blockAction
(if any), and returns a Block<T> instance
combined with the StateRootHash determined from ground zero
(i.e., empty state root). The returned Block<T> is signed by the given
privateKey
.
Declaration
public Block<T> Evaluate(PrivateKey privateKey, IAction blockAction, IStateStore stateStore)
Parameters
Type | Name | Description |
---|---|---|
PrivateKey | privateKey | The miner's private key to be used for signing the block. This must match to the block's Miner and PublicKey. |
IAction | blockAction | An optional BlockAction. |
IStateStore | stateStore | The Libplanet.Blockchain.BlockChain`1.StateStore. |
Returns
Type | Description |
---|---|
Block<T> | The block combined with the resulting StateRootHash.
It is signed by the given |
Remarks
This can be used with only genesis blocks. For blocks with indices greater than zero, use DetermineStateRootHash(BlockChain<T>) overloaded one instead.
Evaluate(PrivateKey, BlockChain<T>)
Evaluates all actions in the Transactions and an optional
BlockAction, and returns
a Block<T> instance combined with the StateRootHash
determined from ground zero (i.e., empty state root). The returned
Block<T> is signed by the given privateKey
.
Declaration
public Block<T> Evaluate(PrivateKey privateKey, BlockChain<T> blockChain)
Parameters
Type | Name | Description |
---|---|---|
PrivateKey | privateKey | The miner's private key to be used for signing the block. This must match to the block's Miner and PublicKey. |
BlockChain<T> | blockChain | The blockchain on which actions are evaluated based. |
Returns
Type | Description |
---|---|
Block<T> | The block combined with the resulting StateRootHash.
It is signed by the given |
Remarks
As blocks have their signatures since the ProtocolVersion 2, it is not usable with blocks of
the earlier ProtocolVersions than 2.
To create a Block<T> instance with ProtocolVersion
less than 2, use Block<T>'s constructors with null
signatures.
Sign(PrivateKey, HashDigest<SHA256>)
Signs the block content with the given stateRootHash
.
Declaration
public Block<T> Sign(PrivateKey privateKey, HashDigest<SHA256> stateRootHash)
Parameters
Type | Name | Description |
---|---|---|
PrivateKey | privateKey | The miner's private key to be used for signing the block. This must match to the block's Miner and PublicKey. |
HashDigest<SHA256> | stateRootHash | The state root hash to include to the input message to sign. |
Returns
Type | Description |
---|---|
Block<T> | The signed block with the |
Remarks
As blocks have their signatures since the ProtocolVersion 2, it is not usable with blocks of
the earlier ProtocolVersions than 2.
To create a Block<T> instance with ProtocolVersion
less than 2, use Block<T>'s constructors with null
signatures.