Class AtomicActionRenderer
A middleware to make action render events to satisfy transactions' atomicity.
Decorates an IActionRenderer instance and filters out render events made by unsuccessful transactions (i.e., transactions with one or more exception-throwing actions).
Inherited Members
Namespace: Libplanet.Blockchain.Renderers
Assembly: Libplanet.dll
Syntax
public sealed class AtomicActionRenderer : IActionRenderer, IRenderer
Remarks
The wrapped ActionRenderer will not receive any RenderActionError(IValue, IActionContext, Exception) events except for block actions, which do not belong to any transactions.
Constructors
| Improve this Doc View SourceAtomicActionRenderer(IActionRenderer)
Creates a new AtomicActionRenderer instance decorating the given
actionRenderer
.
Declaration
public AtomicActionRenderer(IActionRenderer actionRenderer)
Parameters
Type | Name | Description |
---|---|---|
IActionRenderer | actionRenderer | The inner action renderer which has the actual implementations and expects to receive no RenderActionError(IValue, IActionContext, Exception) events. |
Remarks
The wrapped ActionRenderer will not receive any RenderActionError(IValue, IActionContext, Exception) events except for block actions, which do not belong to any transactions.
Properties
| Improve this Doc View SourceActionRenderer
The inner action renderer which has the actual implementations and expects to receive no RenderActionError(IValue, IActionContext, Exception) events.
Declaration
public IActionRenderer ActionRenderer { get; }
Property Value
Type | Description |
---|---|
IActionRenderer |
Remarks
The wrapped ActionRenderer will not receive any RenderActionError(IValue, IActionContext, Exception) events except for block actions, which do not belong to any transactions.
Methods
| Improve this Doc View SourceRenderAction(IValue, IActionContext, IAccountStateDelta)
Does things that should be done right after an action
is executed and applied to the blockchain.
Declaration
public void RenderAction(IValue action, IActionContext context, IAccountStateDelta nextStates)
Parameters
Type | Name | Description |
---|---|---|
Bencodex.Types.IValue | action | An executed action. |
IActionContext | context | The equivalent context object to an object passed to
the |
IAccountStateDelta | nextStates | The states right after this action executed,
which means it is equivalent to the states |
Remarks
It is guaranteed to be called only once for an action
,
and only after applied to the blockchain, unless an exception is thrown during executing
the action
(in that case RenderActionError(IValue, IActionContext, Exception) is called instead) or
once the action
has been unrendered.
Also note that this method is invoked after RenderBlock(Block, Block) method is called
(where its second parameter newTip
contains a transaction the action
belongs to).
RenderActionError(IValue, IActionContext, Exception)
Does the similar things to RenderAction(IValue, IActionContext, IAccountStateDelta), except that this method
is invoked when action
has terminated with an exception.
Declaration
public void RenderActionError(IValue action, IActionContext context, Exception exception)
Parameters
Type | Name | Description |
---|---|---|
Bencodex.Types.IValue | action | An action which threw an exception during execution. |
IActionContext | context | The equivalent context object to an object passed to
the |
Exception | exception | The exception thrown during executing the |
Remarks
Also note that this method is invoked after RenderBlock(Block, Block) method is called
(where its second parameter newTip
contains a transaction the action
belongs to).
RenderBlock(Block, Block)
Does things that should be done right after a new Block is appended to a BlockChain (so that its Tip has changed).
Declaration
public void RenderBlock(Block oldTip, Block newTip)
Parameters
Type | Name | Description |
---|---|---|
Block | oldTip | The previous Tip. |
Block | newTip | The current Tip. |
Remarks
It is guaranteed to be called only once for a block, and only after applied to the blockchain, unless it has been stale due to reorg.
RenderBlockEnd(Block, Block)
Does things that should be done right all actions in a new Block are rendered.
Declaration
public void RenderBlockEnd(Block oldTip, Block newTip)
Parameters
Type | Name | Description |
---|---|---|
Block | oldTip | The previous Tip. |
Block | newTip | The current Tip. |
Remarks
It is guaranteed to be called only once for a block.