Class VolatileStagePolicy<T>
In-memory staged transactions.
Implements
Inherited Members
Namespace: Libplanet.Blockchain.Policies
Assembly: Libplanet.dll
Syntax
public class VolatileStagePolicy<T> : IStagePolicy<T> where T : IAction, new()
Type Parameters
Name | Description |
---|---|
T | An IAction type. It should match to BlockChain<T>'s type parameter. |
Constructors
| Improve this Doc View SourceVolatileStagePolicy()
Creates a new VolatileStagePolicy<T> instance.
Lifetime is configured to 3 hours.
Declaration
public VolatileStagePolicy()
VolatileStagePolicy(TimeSpan)
Creates a new VolatileStagePolicy<T> instance.
Declaration
public VolatileStagePolicy(TimeSpan lifetime)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | lifetime | Volatilizes staged transactions older than this |
Properties
| Improve this Doc View SourceLifetime
Volatilizes staged transactions older than this Lifetime.
Note that transactions older than the lifetime never cannot be staged.
Declaration
public TimeSpan Lifetime { get; }
Property Value
Type | Description |
---|---|
TimeSpan |
Methods
| Improve this Doc View SourceGet(BlockChain<T>, TxId, Boolean)
Gets a staged Transaction<T> by its id
.
Declaration
public 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
public 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
public 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
public 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
public 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
public 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.