Interface IBlockPolicy<T>
An interface to determine if consecutive Block<T>s are valid, and to suggest how difficult a Nonce for a Block<T> to be mined.
Namespace: Libplanet.Blockchain.Policies
Assembly: Libplanet.dll
Syntax
public interface IBlockPolicy<T>
where T : IAction, new()
Type Parameters
| Name | Description |
|---|---|
| T | An IAction type. It should match to Block<T>'s type parameter. |
Methods
| Improve this Doc View SourceGetNextBlockDifficulty(IEnumerable<Block<T>>)
Determines a right Difficulty
for a new Block<T> to be mined
right after the given blocks.
Declaration
int GetNextBlockDifficulty(IEnumerable<Block<T>> blocks)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<Block<T>> | blocks | Consecutive Block<T>s to be followed by a new Block<T> to be mined. |
Returns
| Type | Description |
|---|---|
| Int32 | A right Difficulty for a new Block<T> to be mined. |
ValidateBlocks(IEnumerable<Block<T>>, DateTimeOffset)
Checks if blocks are invalid, and if that
returns the reason.
Note that it returns null when blocks are
valid.
Declaration
InvalidBlockException ValidateBlocks(IEnumerable<Block<T>> blocks, DateTimeOffset currentTime)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<Block<T>> | blocks | Consecutive Block<T>s to validate. |
| DateTimeOffset | currentTime | The current time to be used to validate of Timestamps. Usually UtcNow is used. |
Returns
| Type | Description |
|---|---|
| InvalidBlockException | The reason why the given |