Show / Hide Table of Contents

Class VolatileStagePolicy

An in memory implementation of the IStagePolicy.

This implementation holds on to every unconfirmed Transaction except for the following reasons:

  • A Transaction has been specifically marked to be ignored due to Transaction not being valid.
  • A Transaction has expired due to its staleness.

Additionally, any Transaction with a lower nonce than that of returned by the BlockChain is masked and filtered by default.

Inheritance
Object
VolatileStagePolicy
Implements
IStagePolicy
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 : IStagePolicy

Constructors

| Improve this Doc View Source

VolatileStagePolicy()

Creates a new VolatileStagePolicy instance. By default, Lifetime is set to 10 minutes.

Declaration
public VolatileStagePolicy()
| Improve this Doc View Source

VolatileStagePolicy(TimeSpan)

Creates a new VolatileStagePolicy instance.

Declaration
public VolatileStagePolicy(TimeSpan lifetime)
Parameters
Type Name Description
TimeSpan lifetime

Volatilizes staged transactions older than this TimeSpan. See also Lifetime.

Properties

| Improve this Doc View Source

Lifetime

Lifespan for Transactions. Any Transaction older than this TimeSpan will be considered expired.

Declaration
public TimeSpan Lifetime { get; }
Property Value
Type Description
TimeSpan
Remarks

Expired Transactions cannot be staged.

Methods

| Improve this Doc View Source

Get(BlockChain, TxId, Boolean)

Retrieves a staged Transaction by its id.

Declaration
public Transaction Get(BlockChain blockChain, TxId id, bool filtered = true)
Parameters
Type Name Description
BlockChain blockChain

The BlockChain that the stage belongs to.

TxId id

The Id to get.

Boolean filtered

Whether to filter masked staged Transactions or not. Set to true by default.

Returns
Type Description
Transaction

The staged Transaction associated with id if found, null otherwise.

| Improve this Doc View Source

GetNextTxNonce(BlockChain, Address)

Calculates the next nonce according for given address.

Declaration
public long GetNextTxNonce(BlockChain blockChain, Address address)
Parameters
Type Name Description
BlockChain blockChain

The BlockChain that the stage belongs to.

Address address

The Address to calculate the next nonce for.

Returns
Type Description
Int64

The next appropriate nonce for address.

| Improve this Doc View Source

Ignore(BlockChain, TxId)

Marks given id as ignored.

Declaration
public void Ignore(BlockChain blockChain, TxId id)
Parameters
Type Name Description
BlockChain blockChain

The BlockChain that the stage belongs to.

TxId id

The Id to ignore.

Remarks

If the Transaction associated with id is already staged, this also unstages the Transaction.

| Improve this Doc View Source

Ignores(BlockChain, TxId)

Checks if given id is marked as ignored.

Declaration
public bool Ignores(BlockChain blockChain, TxId id)
Parameters
Type Name Description
BlockChain blockChain

The BlockChain that the stage belongs to.

TxId id

The Id to check.

Returns
Type Description
Boolean

true if id is marked as ignored, false otherwise.

| Improve this Doc View Source

Iterate(BlockChain, Boolean)

Enumerates all staged Transactions.

Declaration
public IEnumerable<Transaction> Iterate(BlockChain blockChain, bool filtered = true)
Parameters
Type Name Description
BlockChain blockChain

The BlockChain that the stage belongs to.

Boolean filtered

Whether to filter masked staged Transactions or not. Set to true by default.

Returns
Type Description
IEnumerable<Transaction>

All staged transactions. No ordering is guaranteed.

| Improve this Doc View Source

Stage(BlockChain, Transaction)

Stages a transaction.

Declaration
public bool Stage(BlockChain blockChain, Transaction transaction)
Parameters
Type Name Description
BlockChain blockChain

The BlockChain that the stage belongs to.

Transaction transaction

The Transaction to be staged.

Returns
Type Description
Boolean

true if staging was successful, false otherwise.

Remarks

This does not throw any exception regardless of whether transaction was successfully staged or not.

If the Id of transaction is marked as ignored, transaction will not be staged.

| Improve this Doc View Source

Unstage(BlockChain, TxId)

Unstages a transaction id.

Declaration
public bool Unstage(BlockChain blockChain, TxId id)
Parameters
Type Name Description
BlockChain blockChain

The BlockChain that the stage belongs to.

TxId id

The Id to unstage.

Returns
Type Description
Boolean

true if unstaging was successful, false otherwise.

Remarks

This does not throw any exception regardless of whether id was successfully unstaged or not.

Implements

IStagePolicy
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium