Show / Hide Table of Contents

Interface IActionRenderer<T>

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

The invocation order of methods for each Block<T> are:

  1. RenderReorg(Block<T>, Block<T>, Block<T>) (one time)
  2. UnrenderAction(IAction, IActionContext, IAccountStateDelta) & UnrenderActionError(IAction, IActionContext, Exception) (zero or more times)
  3. RenderBlock(Block<T>, Block<T>) (one time)
  4. RenderAction(IAction, IActionContext, IAccountStateDelta) & RenderActionError(IAction, IActionContext, Exception) (zero or more times)
  5. RenderBlockEnd(Block<T>, Block<T>) (one time)
  6. RenderReorgEnd(Block<T>, Block<T>, Block<T>) (one time)
Inherited Members
IRenderer<T>.RenderBlock(Block<T>, Block<T>)
IRenderer<T>.RenderReorg(Block<T>, Block<T>, Block<T>)
IRenderer<T>.RenderReorgEnd(Block<T>, Block<T>, Block<T>)
Namespace: Libplanet.Blockchain.Renderers
Assembly: Libplanet.dll
Syntax
public interface IActionRenderer<T> : IRenderer<T> where T : IAction, new()
Type Parameters
Name Description
T

An IAction type. It should match to BlockChain<T>'s type parameter.

Methods

| Improve this Doc View Source

RenderAction(IAction, IActionContext, IAccountStateDelta)

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

Declaration
void RenderAction(IAction action, IActionContext context, IAccountStateDelta nextStates)
Parameters
Type Name Description
IAction 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(IAction, IActionContext, Exception) is called instead) or once the action has been unrendered.

Also note that this method is invoked after RenderBlock(Block<T>, Block<T>) method is called (where its second parameter newTip contains a transaction the action belongs to).

The reason why the parameter action takes IAction instead of T is because it can take block actions (BlockAction) besides transaction actions (Actions).

| Improve this Doc View Source

RenderActionError(IAction, IActionContext, Exception)

Does the similar things to RenderAction(IAction, IActionContext, IAccountStateDelta), except that this method is invoked when action has terminated with an exception.

Declaration
void RenderActionError(IAction action, IActionContext context, Exception exception)
Parameters
Type Name Description
IAction 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<T>, Block<T>) method is called (where its second parameter newTip contains a transaction the action belongs to).

The reason why the parameter action takes IAction instead of T is because it can take block actions (BlockAction) besides transaction actions (Actions).

| Improve this Doc View Source

RenderBlockEnd(Block<T>, Block<T>)

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

Declaration
void RenderBlockEnd(Block<T> oldTip, Block<T> newTip)
Parameters
Type Name Description
Block<T> oldTip

The previous Tip.

Block<T> newTip

The current Tip.

Remarks

It is guaranteed to be called only once for a block.

| Improve this Doc View Source

UnrenderAction(IAction, IActionContext, IAccountStateDelta)

Does things that should be undone right after the given action is invalidated (mostly due to reorg, i.e., a block which the action has belonged to becomes considered stale).

This method takes the equivalent arguments to RenderAction(IAction, IActionContext, IAccountStateDelta) method.

Declaration
void UnrenderAction(IAction action, IActionContext context, IAccountStateDelta nextStates)
Parameters
Type Name Description
IAction action

A stale 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

As a rule of thumb, this should be the inverse of RenderAction(IAction, IActionContext, IAccountStateDelta) method with redrawing the graphics on the display at the finish.

| Improve this Doc View Source

UnrenderActionError(IAction, IActionContext, Exception)

Does the similar things to UnrenderAction(IAction, IActionContext, IAccountStateDelta), except that this method is invoked when action has terminated with an exception.

This method takes the equivalent arguments to RenderActionError(IAction, IActionContext, Exception) method.

Declaration
void UnrenderActionError(IAction action, IActionContext context, Exception exception)
Parameters
Type Name Description
IAction 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

The reason why the parameter action takes IAction instead of T is because it can take block actions (BlockAction) besides transaction actions (Actions).

  • Improve this Doc
  • View Source
Back to top Copyright © 2019–2020 Planetarium