Class BlockPolicy<T>
A default implementation of IBlockPolicy<T> interface.
Implements
Namespace: Libplanet.Blockchain.Policies
Assembly: Libplanet.dll
Syntax
public class BlockPolicy<T> : object, IBlockPolicy<T> where T : IAction, new()
Type Parameters
Constructors
| Improve this Doc View SourceBlockPolicy(IAction, Int32, Int64, Int32, Predicate<Transaction<T>>)
Creates a BlockPolicy<T> with configuring
Block
Declaration
public BlockPolicy(IAction blockAction = null, int blockIntervalMilliseconds = 5000, long minimumDifficulty = null, int difficultyBoundDivisor = 128, Predicate<Transaction<T>> doesTransactionFollowPolicy = null)
Parameters
Type | Name | Description |
---|---|---|
IAction | blockAction | A block action to execute and be rendered for every block. |
Int32 | blockIntervalMilliseconds | Configures
Block |
Int64 | minimumDifficulty | Configures
Libplanet. |
Int32 | difficultyBoundDivisor | Configures
Libplanet. |
Predicate<Transaction<T>> | doesTransactionFollowPolicy | A predicate that determines if the transaction follows the block policy. |
BlockPolicy(IAction, TimeSpan, Int64, Int32, Predicate<Transaction<T>>)
Creates a BlockPolicy<T> with configuring
Block
Declaration
public BlockPolicy(IAction blockAction, TimeSpan blockInterval, long minimumDifficulty, int difficultyBoundDivisor, Predicate<Transaction<T>> doesTransactionFollowPolicy = null)
Parameters
Type | Name | Description |
---|---|---|
IAction | blockAction | A block action to execute and be rendered for every block. |
Time |
blockInterval | Configures Block |
Int64 | minimumDifficulty | Configures
Libplanet. |
Int32 | difficultyBoundDivisor | Configures
Libplanet. |
Predicate<Transaction<T>> | doesTransactionFollowPolicy | A predicate that determines if the transaction follows the block policy. |
Properties
| Improve this Doc View SourceBlockAction
Declaration
public IAction BlockAction { get; }
Property Value
Type | Description |
---|---|
IAction |
BlockInterval
An appropriate interval between consecutive Block<T>s. It is usually from 20 to 30 seconds.
If a previous interval took longer than this GetNextBlockDifficulty(BlockChain<T>) method raises the Difficulty. If it took shorter than this Difficulty is dropped.
Declaration
public TimeSpan BlockInterval { get; }
Property Value
Type | Description |
---|---|
Time |
Methods
| Improve this Doc View SourceDoesTransactionFollowsPolicy(Transaction<T>)
Declaration
public bool DoesTransactionFollowsPolicy(Transaction<T> transaction)
Parameters
Type | Name | Description |
---|---|---|
Transaction<T> | transaction |
Returns
Type | Description |
---|---|
Boolean |
GetNextBlockDifficulty(BlockChain<T>)
Declaration
public long GetNextBlockDifficulty(BlockChain<T> blocks)
Parameters
Type | Name | Description |
---|---|---|
Block |
blocks |
Returns
Type | Description |
---|---|
Int64 |
ValidateNextBlock(BlockChain<T>, Block<T>)
Declaration
public InvalidBlockException ValidateNextBlock(BlockChain<T> blocks, Block<T> nextBlock)
Parameters
Type | Name | Description |
---|---|---|
Block |
blocks | |
Block<T> | nextBlock |
Returns
Type | Description |
---|---|
Invalid |