Class BlockPolicy<T>
A default implementation of IBlockPolicy<T> interface.
Implements
IBlockPolicy<T>
Inherited Members
Namespace: Libplanet.Blockchain.Policies
Assembly: Libplanet.dll
Syntax
public class BlockPolicy<T> : IBlockPolicy<T> where T : IAction, new()
Type Parameters
Name | Description |
---|---|
T | An IAction type. It should match to Block<T>'s type parameter. |
Constructors
| Improve this Doc View SourceBlockPolicy(Int32)
Creates a BlockPolicy<T> with configuring BlockInterval in milliseconds.
Declaration
public BlockPolicy(int blockIntervalMilliseconds = 5000)
Parameters
Type | Name | Description |
---|---|---|
Int32 | blockIntervalMilliseconds | Configures BlockInterval in milliseconds. 5000 milliseconds by default. |
BlockPolicy(TimeSpan)
Creates a BlockPolicy<T> with configuring BlockInterval.
Declaration
public BlockPolicy(TimeSpan blockInterval)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | blockInterval | Configures BlockInterval. |
Properties
| Improve this Doc View SourceBlockInterval
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(IEnumerable<Block<T>>) method raises the Difficulty. If it took shorter than this Difficulty is dropped.
Declaration
public TimeSpan BlockInterval { get; }
Property Value
Type | Description |
---|---|
TimeSpan |
Methods
| Improve this Doc View SourceGetNextBlockDifficulty(IEnumerable<Block<T>>)
Declaration
public int GetNextBlockDifficulty(IEnumerable<Block<T>> blocks)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Block<T>> | blocks |
Returns
Type | Description |
---|---|
Int32 |
ValidateBlocks(IEnumerable<Block<T>>, DateTimeOffset)
Declaration
public InvalidBlockException ValidateBlocks(IEnumerable<Block<T>> blocks, DateTimeOffset currentTime)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Block<T>> | blocks | |
DateTimeOffset | currentTime |
Returns
Type | Description |
---|---|
InvalidBlockException |