Show / Hide Table of Contents

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 Source

BlockAction

An IAction to execute and be rendered for every block, if any.

Declaration
IAction BlockAction { get; }
Property Value
Type Description
IAction
| Improve this Doc View Source

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 Source

GetMaxTransactionsBytes(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 nextBlock.

Block nextBlock

The next block to append to blockChain.

Returns
Type Description
BlockPolicyViolationException

A BlockPolicyViolationException with a description as to why given nextBlock is invalid, or null if nextBlock is valid.

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).

| Improve this Doc View Source

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 transaction

The Transaction to consider.

Returns
Type Description
TxPolicyViolationException

A TxPolicyViolationException with a description as to why given transaction is invalid, or null if transaction is valid.

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.
This is called separately from ValidateNextBlock(BlockChain, Block) from a BlockChain.
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium