Class ValidatingActionRenderer<T>
Validates if rendering events are in the correct order according to the documented automata (see also the docs for IRenderer<T> and IActionRenderer<T>) using profiling-guided analysis.
Inherited Members
Namespace: Libplanet.Blockchain.Renderers.Debug
Assembly: Libplanet.dll
Syntax
public class ValidatingActionRenderer<T> : RecordingActionRenderer<T>, 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. |
Constructors
| Improve this Doc View SourceValidatingActionRenderer(Action<InvalidRenderException<T>>)
Creates a new ValidatingActionRenderer<T> instance.
Declaration
public ValidatingActionRenderer(Action<InvalidRenderException<T>> onError = null)
Parameters
Type | Name | Description |
---|---|---|
Action<InvalidRenderException<T>> | onError | An optional event handler which is triggered when invalid render events occur. |
Properties
| Improve this Doc View SourceBlockChain
The chain that publishes the render events. More stricter validations are conducted if it's configured.
Declaration
public BlockChain<T> BlockChain { get; set; }
Property Value
Type | Description |
---|---|
BlockChain<T> |
Methods
| Improve this Doc View SourceRenderAction(IAction, IActionContext, IAccountStateDelta)
Does things that should be done right after an action
is executed and applied to the blockchain.
Declaration
public override 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 |
IAccountStateDelta | nextStates | The states right after this action executed,
which means it is equivalent to the states |
Overrides
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).
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
public override 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 |
Exception | exception | The exception thrown during executing the |
Overrides
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).
RenderBlock(Block<T>, Block<T>)
Does things that should be done right after a new Block<T> is appended to a BlockChain<T> (so that its Tip has changed).
Declaration
public override void RenderBlock(Block<T> oldTip, Block<T> newTip)
Parameters
Type | Name | Description |
---|---|---|
Block<T> | oldTip | The previous Tip. |
Block<T> | newTip | The current Tip. |
Overrides
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 (for that case, RenderReorg(Block<T>, Block<T>, Block<T>) is called in advance).
RenderBlockEnd(Block<T>, Block<T>)
Does things that should be done right all actions in a new Block<T> are rendered.
Declaration
public override void RenderBlockEnd(Block<T> oldTip, Block<T> newTip)
Parameters
Type | Name | Description |
---|---|---|
Block<T> | oldTip | The previous Tip. |
Block<T> | newTip | The current Tip. |
Overrides
Remarks
It is guaranteed to be called only once for a block.
RenderReorg(Block<T>, Block<T>, Block<T>)
Does things that should be done right before reorg happens to a BlockChain<T>.
Declaration
public override void RenderReorg(Block<T> oldTip, Block<T> newTip, Block<T> branchpoint)
Parameters
Type | Name | Description |
---|---|---|
Block<T> | oldTip | The Tip right before reorg. |
Block<T> | newTip | The Tip after reorg. |
Block<T> | branchpoint | The highest common Block<T> between
|
Overrides
Remarks
For every call to this method, calls to
RenderBlock(Block<T>, Block<T>) and
RenderReorgEnd(Block<T>, Block<T>, Block<T>) methods with the same
newTip
is made too. Note that this method is guaranteed to be called
before RenderBlock(Block<T>, Block<T>) method for the same
newTip
.
RenderReorgEnd(Block<T>, Block<T>, Block<T>)
Does things that should be done right after reorg happens to a BlockChain<T>.
Declaration
public override void RenderReorgEnd(Block<T> oldTip, Block<T> newTip, Block<T> branchpoint)
Parameters
Type | Name | Description |
---|---|---|
Block<T> | oldTip | The Tip right before reorg. |
Block<T> | newTip | The Tip after reorg. |
Block<T> | branchpoint | The highest common Block<T> between
|
Overrides
Remarks
Note that this method is guaranteed to be called after
RenderReorg(Block<T>, Block<T>, Block<T>) and
RenderBlock(Block<T>, Block<T>) methods for the same
newTip
.
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
public override 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 |
IAccountStateDelta | nextStates | The states right after this action executed,
which means it is equivalent to the states |
Overrides
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.
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
public override 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 |
Exception | exception | The exception thrown during executing the |
Overrides
Remarks
The reason why the parameter action
takes
IAction instead of T
is because it can take
block actions (BlockAction) besides transaction
actions (Actions).