Interface IBlockPolicy
An interface to determine if consecutive Blocks are valid.
An implementation of this interface should perform all policy dependent checks, such as whether a Block has the right difficulty, a Transaction has the right signer, etc.
Note that all index dependent sub-policies are ignored for genesis Blocks.
Namespace: Libplanet.Blockchain.Policies
Assembly: Libplanet.dll
Syntax
public interface IBlockPolicy
Properties
| Improve this Doc View SourceBlockAction
An IAction to execute and be rendered for every block, if any.
Declaration
IAction BlockAction { get; }
Property Value
Type | Description |
---|---|
IAction |
FeeCalculator
An interface to determine if consecutive Blocks are valid.
An implementation of this interface should perform all policy dependent checks, such as whether a Block has the right difficulty, a Transaction has the right signer, etc.
Note that all index dependent sub-policies are ignored for genesis Blocks.
Declaration
[Pure]
IFeeCalculator FeeCalculator { get; }
Property Value
Type | Description |
---|---|
IFeeCalculator |
Methods
| Improve this Doc View SourceGetMaxTransactionsBytes(Int64)
Gets the maximum length of Transactions in bytes.
Declaration
long GetMaxTransactionsBytes(long index)
Parameters
Type | Name | Description |
---|---|---|
Int64 | index | The Index of the Block for which this constraint should apply. |
Returns
Type | Description |
---|---|
Int64 | The maximum length of Transactions in bytes to accept. |
GetMaxTransactionsPerBlock(Int64)
Gets the maximum number of Transactions allowed for a valid Block.
Declaration
[Pure]
int GetMaxTransactionsPerBlock(long index)
Parameters
Type | Name | Description |
---|---|---|
Int64 | index | The Index of the Block for which this constraint should apply. |
Returns
Type | Description |
---|---|
Int32 | The maximum number of Transactions allowed for a valid Block can accept. |
GetMaxTransactionsPerSignerPerBlock(Int64)
Gets the maximum number of Transactions allowed per signer for a valid Block.
Declaration
[Pure]
int GetMaxTransactionsPerSignerPerBlock(long index)
Parameters
Type | Name | Description |
---|---|---|
Int64 | index | The Index of the Block for which this constraint should apply. |
Returns
Type | Description |
---|---|
Int32 | The maximum number of Transactions allowed per signer for a valid Block can accept. |
GetMinTransactionsPerBlock(Int64)
Gets the minimum number of Transactions allowed for a valid Block.
Declaration
[Pure]
int GetMinTransactionsPerBlock(long index)
Parameters
Type | Name | Description |
---|---|---|
Int64 | index | The Index of the Block for which this constraint should apply. |
Returns
Type | Description |
---|---|
Int32 | The minimum number of Transactions allowed for a valid Block can accept. |
ValidateNextBlock(BlockChain, Block)
Checks if a Block can be appended to the given BlockChain.
Declaration
BlockPolicyViolationException ValidateNextBlock(BlockChain blockChain, Block nextBlock)
Parameters
Type | Name | Description |
---|---|---|
BlockChain | blockChain | The target BlockChain to
append |
Block | nextBlock | The next block to append to
|
Returns
Type | Description |
---|---|
BlockPolicyViolationException | A BlockPolicyViolationException with a description
as to why given |
Remarks
Note that ValidateNextBlockTx(BlockChain, Transaction) will be called separately from a BlockChain when appending a Block. Hence, to reduce redundancy, an implementation of this interface should not call ValidateNextBlockTx(BlockChain, Transaction).
ValidateNextBlockTx(BlockChain, Transaction)
Checks if a Transaction can be included in a yet to be mined Block that can be appended to the given BlockChain.
Declaration
TxPolicyViolationException ValidateNextBlockTx(BlockChain blockChain, Transaction transaction)
Parameters
Type | Name | Description |
---|---|---|
BlockChain | blockChain | The target BlockChain to include
given |
Transaction | transaction | The Transaction to consider. |
Returns
Type | Description |
---|---|
TxPolicyViolationException | A TxPolicyViolationException with a description
as to why given |
Remarks
This is used in two different cases:
- When selecting which Transaction to include when mining a next Block.
- When appending a Block
with
transaction
to a BlockChain.