Show / Hide Table of Contents

Interface IActionRenderer

Listens state changes of every step of actions, besides blocks, on a BlockChain<T>. If you need more fine-grained events than IRenderer, implement this interface instead.

The invocation order of methods for each Block are:

  1. RenderBlock(Block, Block) (one time)
  2. RenderAction(IValue, IActionContext, IAccountStateDelta) & RenderActionError(IValue, IActionContext, Exception) (zero or more times)
  3. RenderBlockEnd(Block, Block) (one time)
Inherited Members
IRenderer.RenderBlock(Block, Block)
Namespace: Libplanet.Blockchain.Renderers
Assembly: Libplanet.dll
Syntax
public interface IActionRenderer : IRenderer
Remarks

Although Transactions affect the states in the IStateStore all or nothing at all (i.e., atomically), IActionRenderer receives all action-related events (RenderAction(IValue, IActionContext, IAccountStateDelta)/RenderActionError(IValue, IActionContext, Exception)) immediately without buffering, which means actions are rendered even before whether there are any actions throwing an exception in the same transaction is determined. In other words, for IActionRenderers, it is not guaranteed that actions in a transaction are atomic.

If your action renderer expects to receive only render events about actions belonging successful transactions, wrap your action renderer with AtomicActionRenderer.

Methods

| Improve this Doc View Source

RenderAction(IValue, IActionContext, IAccountStateDelta)

Does things that should be done right after an action is executed and applied to the blockchain.

Declaration
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 action's Execute(IActionContext) method. That means PreviousStates are the states right before this action executed. For the states after this action executed, use the nextStates argument instead.

IAccountStateDelta nextStates

The states right after this action executed, which means it is equivalent to the states action's Execute(IActionContext) method returned.

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).

| Improve this Doc View Source

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
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 action's Execute(IActionContext) method. That means PreviousStates are the states right before this action executed.

Exception exception

The exception thrown during executing the action.

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).

| Improve this Doc View Source

RenderBlockEnd(Block, Block)

Does things that should be done right all actions in a new Block are rendered.

Declaration
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.

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