Show / Hide Table of Contents

Interface IStagePolicy<T>

An 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 the BlockChain<T>'s type parameter.

Remarks

Every operation of an implementation of this interface must be thread-safe.

Methods

| Improve this Doc View Source

Get(BlockChain<T>, TxId, Boolean)

Retrieves a staged Transaction<T> by its id.

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

The BlockChain<T> that the stage belongs to.

TxId id

The Id to get.

Boolean filtered

Whether to filter masked staged Transaction<T>s or not. Set to true by default.

Returns
Type Description
Transaction<T>

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

| Improve this Doc View Source

GetNextTxNonce(BlockChain<T>, Address)

Calculates the next nonce according for given address.

Declaration
long GetNextTxNonce(BlockChain<T> blockChain, Address address)
Parameters
Type Name Description
BlockChain<T> blockChain

The BlockChain<T> 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<T>, TxId)

Marks given id as ignored.

Declaration
void Ignore(BlockChain<T> blockChain, TxId id)
Parameters
Type Name Description
BlockChain<T> blockChain

The BlockChain<T> that the stage belongs to.

TxId id

The Id to ignore.

Remarks

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

| Improve this Doc View Source

Ignores(BlockChain<T>, TxId)

Checks if given id is marked as ignored.

Declaration
bool Ignores(BlockChain<T> blockChain, TxId id)
Parameters
Type Name Description
BlockChain<T> blockChain

The BlockChain<T> 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<T>, Boolean)

Enumerates all staged Transaction<T>s.

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

The BlockChain<T> that the stage belongs to.

Boolean filtered

Whether to filter masked staged Transaction<T>s or not. Set to true by default.

Returns
Type Description
IEnumerable<Transaction<T>>

All staged transactions. No ordering is guaranteed.

| Improve this Doc View Source

Stage(BlockChain<T>, Transaction<T>)

Stages a transaction.

Declaration
bool Stage(BlockChain<T> blockChain, Transaction<T> transaction)
Parameters
Type Name Description
BlockChain<T> blockChain

The BlockChain<T> that the stage belongs to.

Transaction<T> transaction

The Transaction<T> 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<T>, TxId)

Unstages a transaction id.

Declaration
bool Unstage(BlockChain<T> blockChain, TxId id)
Parameters
Type Name Description
BlockChain<T> blockChain

The BlockChain<T> 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.

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