Namespace Libplanet.Action
Classes
ActionTypeAttribute
Indicates that an action class (i.e., a class implementing IAction) can be held by transactions and blocks. It also gives an action class a TypeIdentifier for serialization and deserialization.
AddressStateMap
An immutable key–value data structure to represent states of multiple accounts. Keys are an account Address, and values are their state.
Since this implements IImmutableDictionary<TKey,TValue> interface, the usage is same.
MissingActionTypeException
The exception that is thrown when an action class without ActionTypeAttribute is tried to used with PolymorphicAction<T>.
PolymorphicAction<T>
A decorator to enable subtype polymorphism for action classes.
By convention, concrete action subclasses are named with verb
phrases, e.g., Heal
, Sell
.
One downside of this compared to the vanilla IAction is the fact that it uses reflection under the hood. This may cause compatibility issues on certain platforms, and is slightly slower.
Interfaces
IAccountStateDelta
An interface to manipulate account states with maintaining the set of UpdatedAddresses.
It is like a map which is virtually initialized such
that every possible Address exists and
is mapped to null
. That means that:
- it does not have length,
- its index getter never throws
KeyNotFoundException,
but returns
null
instead, and - filling an Address with
null
state cannot be distinguished from the Address having never been set to any state.
IAction
An in-game action. Every action should be replayable, because multiple nodes in a network should execute an action and get the same result.
A “class” which implements this interface is analogous to a function, and its instance is analogous to a partial function application, in other words, a function with some bound arguments. Those parameters that will be bound at runtime should be represented as fields or properties in an action class, and bound argument values to these parameters should be received through a constructor parameters of that class.
IActionContext
Contextual data determined by a transaction and a block. Passed to Execute(IActionContext) method.
IRandom
An pseudorandom number generator interface equivalent to Random.
Although these two types have similar shapes, they are not compatible (i.e., disallowed to be casted to each other).
Delegates
AccountStateGetter
An delegate to provide read-only view of account states.
Gets an account state of the given
address
.
If the given address
has never been set
its account status, returns null
instead of throwing
any exception.