Show / Hide Table of Contents

Interface IActionContext

Contextual data determined by a transaction and a block. Passed to Execute(IActionContext) method.

Namespace: Libplanet.Action
Assembly: Libplanet.Action.dll
Syntax
public interface IActionContext

Properties

| Improve this Doc View Source

BlockAction

Whether this action is executed as a block action. false if it belongs to a transaction.

Declaration
[Pure]
bool BlockAction { get; }
Property Value
Type Description
Boolean
| Improve this Doc View Source

BlockIndex

The Index of the Block that contains the IAction.

Declaration
[Pure]
long BlockIndex { get; }
Property Value
Type Description
Int64
| Improve this Doc View Source

BlockProtocolVersion

The ProtocolVersion of the Block that contains the IAction.

Declaration
[Pure]
int BlockProtocolVersion { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

Miner

The Miner of the Block that contains the IAction.

Declaration
[Pure]
Address Miner { get; }
Property Value
Type Description
Address
| Improve this Doc View Source

PreviousState

A null delta of states, which means it represents the states before IAction executes.

Although a IAccount instance is immutable, it has several manipulative methods that returns new IAccount instances with some "dirty" states. These kinds of dirty IAccount instances can be returned by Execute(IActionContext) method.

Declaration
[Pure]
IAccount PreviousState { get; }
Property Value
Type Description
IAccount
| Improve this Doc View Source

Random

An initialized pseudorandom number generator. Its seed (state) is determined by a block and a transaction, which is deterministic so that every node can replay the same action and then reproduce the same result, while neither a single block miner nor a single transaction signer can predict the result and cheat.

Declaration
IRandom Random { get; }
Property Value
Type Description
IRandom

A random object that shares interface mostly equivalent to Random.

| Improve this Doc View Source

Rehearsal

Whether an IAction is being executed during “rehearsal mode”, that there is nothing in PreviousState.

Declaration
[Pure]
bool Rehearsal { get; }
Property Value
Type Description
Boolean
| Improve this Doc View Source

Signer

The Signer of the Transaction that contains the IAction to be executed. If the IAction is not part of a Transaction, e.g. , this is set to Miner instead.

Declaration
[Pure]
Address Signer { get; }
Property Value
Type Description
Address
| Improve this Doc View Source

TxId

The Id of the Transaction that contains the IAction. If the IAction is not part of a Transaction, e.g. , this is set to null.

Declaration
[Pure]
TxId? TxId { get; }
Property Value
Type Description
Nullable<TxId>

Methods

| Improve this Doc View Source

GasLimit()

Returns the limit gas of the current action.

Declaration
[Pure]
long GasLimit()
Returns
Type Description
Int64

The limit gas of the current action.

| Improve this Doc View Source

GasUsed()

Returns the total gas used by the current action.

Declaration
[Pure]
long GasUsed()
Returns
Type Description
Int64

The total gas used by the current action.

| Improve this Doc View Source

GetUnconsumedContext()

Returns a clone of this context, except that its Random has the unconsumed state (with the same seed). The clone and its original are a distinct instance each other, in other words, one's state transfer must not affect the other one (i.e., consuming Random source should be local to a context instance).

Declaration
[Pure]
IActionContext GetUnconsumedContext()
Returns
Type Description
IActionContext

A clone instance, which is distinct from its original. Its internal state is entirely equivalent to the original's unconsumed initial state.

| Improve this Doc View Source

UseGas(Int64)

Consumes the specified amount of gas.

Declaration
void UseGas(long gas)
Parameters
Type Name Description
Int64 gas

The amount of gas to consume.

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