Interface IStagePolicy<T>
The interface to configure a BlockChain<T>'s strategy to deal with staged transactions.
Namespace: Libplanet.Blockchain.Policies
Assembly: Libplanet.dll
Syntax
public interface IStagePolicy<T>
where T : IAction, new()
Type Parameters
Name | Description |
---|---|
T | An IAction type. It should match to BlockChain<T>'s type parameter. |
Remarks
Every operation on an object implementing this must be thread-safe.
Methods
| Improve this Doc View SourceGet(BlockChain<T>, TxId, Boolean)
Gets a staged Transaction<T> by its id
.
Declaration
Transaction<T> Get(BlockChain<T> blockChain, TxId id, bool includeUnstaged)
Parameters
Type | Name | Description |
---|---|---|
BlockChain<T> | blockChain | The chain that the stage belongs to. |
TxId | id | The Id to get. |
Boolean | includeUnstaged | Whether to include transactions that had once staged but unstaged then. |
Returns
Type | Description |
---|---|
Transaction<T> | A staged transaction if found. If it had never staged |
Ignore(BlockChain<T>, TxId)
Marks a transaction as ignored, so that it will be never staged.
Declaration
void Ignore(BlockChain<T> blockChain, TxId id)
Parameters
Type | Name | Description |
---|---|---|
BlockChain<T> | blockChain | The chain that the stage belongs to. |
TxId | id | The Id to ignore. |
Remarks
If the transaction is already in the stage, this method does nothing.
Ignores(BlockChain<T>, TxId)
Checks if a transaction should be ignored for any reasons (for example, it is already staged or marked as ignored).
Declaration
bool Ignores(BlockChain<T> blockChain, TxId id)
Parameters
Type | Name | Description |
---|---|---|
BlockChain<T> | blockChain | The chain that the stage belongs to. |
TxId | id | The Id to check. |
Returns
Type | Description |
---|---|
Boolean |
|
Iterate(BlockChain<T>)
Enumerates all staged transaction IDs.
Declaration
IEnumerable<Transaction<T>> Iterate(BlockChain<T> blockChain)
Parameters
Type | Name | Description |
---|---|---|
BlockChain<T> | blockChain | The chain of the stage to enumerate. |
Returns
Type | Description |
---|---|
IEnumerable<Transaction<T>> | Staged transactions. The earliest staged transaction goes first, and the latest staged transaction goes last. |
Stage(BlockChain<T>, Transaction<T>)
Stages a transaction
.
Declaration
void Stage(BlockChain<T> blockChain, Transaction<T> transaction)
Parameters
Type | Name | Description |
---|---|---|
BlockChain<T> | blockChain | The chain to stage the |
Transaction<T> | transaction | The Transaction<T> to be staged. |
Remarks
It does not throw any exception even if the transaction
has
already been staged. It does nothing either if the transaction
has
marked as ignored (using Ignore(BlockChain<T>, TxId) method).
Unstage(BlockChain<T>, TxId)
Removes a transaction id
from the stage.
Declaration
void Unstage(BlockChain<T> blockChain, TxId id)
Parameters
Type | Name | Description |
---|---|---|
BlockChain<T> | blockChain | The chain to unstage the |
TxId | id | The Id to remove. |
Remarks
It does not throw any exception even if the id
has never
been staged.