Namespace Libplanet.Action
Classes
ActionEvaluation
A record type to represent an evaluation plan and result of a single action.
ActionEvaluator<T>
Class responsible for handling of IAction evaluations.
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.
CurrencyPermissionException
The exception that is thrown when a TransactionSigner has no rights to mint a Currency or burn assets of a Currency.
DuplicateActionTypeIdentifierException
An exception that is thrown when multiple action types are associated with the same TypeIdentifier.
ExtractableException
Extension methods for IExtractableException and other
InsufficientBalanceException
The exception that is thrown when a sender has less Balance than amount to transfer or an owner has less Balance than amount to burn.
MissingActionTypeException
The exception that is thrown when an action class without ActionTypeAttribute is tried to used with PolymorphicAction<T>.
NullAction
An action implementation which does nothing for filling type parameter taking of IAction.
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.
RandomExtensions
This extension class provides some convenient methods to deal with IRandom.
SupplyOverflowException
The exception thrown when a minter tries to mint a currency such that the resulting total supply exceed the maximum amount.
TotalSupplyNotTrackableException
The exception thrown when GetTotalSupply(Currency) was called on a
legacy untracked currency with TotalSupplyTrackable set to
false
.
UnexpectedlyTerminatedActionException
The exception that is thrown during an IAction is being evaluated.
The actual exception that the Action threw
is stored in the
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:
IAccountStateView
An interface to fetch account states.
It is like a readonly map which is virtually initialized such that every possible Address exists and is mapped to null. That means that:
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.
From a perspective of security, an action class belongs to the network protocol, and property values in an action belong to a node's will (i.e., a user/player's choice). That means if you define an action class it also defines what every honest node can do in the network. Even if a malicious node changes their own action code it won't affect other honest nodes in the network.
For example, where honest nodes share the common action
Heal(Target) => PreviousStates[Target] + 1
, suppose a malicious
node m
changes their own Heal
action code to
Heal(Target) => PreviousStates[Target] + 2
(2 instead of 1),
and then send an action Heal(m)
.
Fortunately, this action does not work as m
's intention,
because the changed code in itself is not used by other honest nodes,
so they still increase only 1, not 2. The effect of that double healing
is a sort of “illusion” only visible to the malicious node
alone.
In conclusion, action code is a part of the protocol and it works with consensus in the network, so only things each node can affect the network in general is property values of each action they sign and send, not code of an action.
IActionContext
Contextual data determined by a transaction and a block. Passed to Execute(IActionContext) method.
IExtractableException
Marks an exception type as able to extract its metadata, so that these metadata can be stored as a part of TxFailure.
IRandom
An pseudorandom number generator interface equivalent to
Although these two types have similar shapes, they are not compatible (i.e., disallowed to be casted to each other).
Delegates
AccountBalanceGetter
An delegate to provide read-only view of account balances.
Gets address
' balance of the given currency
.
AccountStateGetter
An delegate to provide read-only view of account states.
Gets states associated with the specified account addresses
.
If some states associated with the specified account addresses
have
never been set these absent states are represented as null.
TotalSupplyGetter
An delegate to provide a view of total supply of a currency.
Gets the total supply of the given currency
.