Show / Hide Table of Contents

Class VolatileStagePolicy<T>

In-memory staged transactions.

Inheritance
Object
VolatileStagePolicy<T>
Implements
IStagePolicy<T>
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
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 Source

VolatileStagePolicy()

Creates a new VolatileStagePolicy<T> instance.

Lifetime is configured to 3 hours.

Declaration
public VolatileStagePolicy()
| Improve this Doc View Source

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 lifetime. See also the Lifetime property.

Properties

| Improve this Doc View Source

Lifetime

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 Source

Get(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 null is returned.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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

true if a transaction should be ignored. Otherwise, false.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

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).

| Improve this Doc View Source

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 id.

TxId id

The Id to remove.

Remarks

It does not throw any exception even if the id has never been staged.

Implements

IStagePolicy<T>
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2021 Planetarium