Interface IActionContext
Contextual data determined by a transaction and a block. Passed to Execute(IActionContext) method.
Namespace: Libplanet.Action
Assembly: Libplanet.dll
Syntax
public interface IActionContext
Properties
| Improve this Doc View SourceBlockIndex
Block index of a transaction that an executed IAction belongs to.
Declaration
long BlockIndex { get; }
Property Value
Type | Description |
---|---|
Int64 |
Miner
Address of a block miner account.
Declaration
Address Miner { get; }
Property Value
Type | Description |
---|---|
Address |
PreviousStateRootHash
A state root hash at the PreviousStates. It can cause file I/O interrupt. It will be return null if the implementation or your chain didn't support the state root hash feature.
Declaration
HashDigest<SHA256>? PreviousStateRootHash { get; }
Property Value
Type | Description |
---|---|
Nullable<HashDigest<SHA256>> |
PreviousStates
A null delta of states, which means it represents the states before IAction executes.
Although a IAccountStateDelta instance is immutable, it has several manipulative methods that returns new IAccountStateDelta instances with some "dirty" states. These kinds of dirty IAccountStateDelta instances can be returned by Execute(IActionContext) method.
Declaration
IAccountStateDelta PreviousStates { get; }
Property Value
Type | Description |
---|---|
IAccountStateDelta |
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 |
Rehearsal
Whether an IAction is being executed during “rehearsal mode”, that there is nothing in PreviousStates.
Declaration
bool Rehearsal { get; }
Property Value
Type | Description |
---|---|
Boolean |
See Also
| Improve this Doc View SourceSigner
Declaration
Address Signer { get; }
Property Value
Type | Description |
---|---|
Address |
Methods
| Improve this Doc View SourceGetUnconsumedContext()
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
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. |