Class AnonymousRenderer<T>
A renderer that invokes its callbacks.
This class is useful when you want an one-use ad-hoc implementation (i.e., Java-style anonymous class) of IRenderer<T> interface.
Implements
Namespace: Libplanet.Blockchain.Renderers
Assembly: Libplanet.dll
Syntax
public class AnonymousRenderer<T> : object, IRenderer<T> where T : IAction, new()
Type Parameters
Name | Description |
---|---|
T | An IAction type. It should match to BlockChain<T>'s type parameter. |
Examples
With object initializers, you can easily make an one-use renderer:
var renderer = new AnonymousRenderer<ExampleAction>
{
BlockRenderer = (oldTip, newTip) =>
{
// Implement RenderBlock() here.
};
};
Properties
| Improve this Doc View SourceBlockRenderer
A callback function to be invoked together with RenderBlock(Block<T>, Block<T>).
Declaration
public Action<Block<T>, Block<T>>? BlockRenderer { get; set; }
Property Value
Type | Description |
---|---|
Nullable<Libplanet.Action<Block<T>, Block<T>>> |
ReorgEndRenderer
A callback function to be invoked together with RenderReorgEnd(Block<T>, Block<T>, Block<T>).
Declaration
public Action<Block<T>, Block<T>, Block<T>>? ReorgEndRenderer { get; set; }
Property Value
Type | Description |
---|---|
Nullable<Libplanet.Action<Block<T>, Block<T>, Block<T>>> |
ReorgRenderer
A callback function to be invoked together with RenderReorg(Block<T>, Block<T>, Block<T>).
Declaration
public Action<Block<T>, Block<T>, Block<T>>? ReorgRenderer { get; set; }
Property Value
Type | Description |
---|---|
Nullable<Libplanet.Action<Block<T>, Block<T>, Block<T>>> |
Methods
| Improve this Doc View SourceRenderBlock(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 void RenderBlock(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, 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).
RenderReorg(Block<T>, Block<T>, Block<T>)
Does things that should be done right before reorg happens to a BlockChain<T>.
Declaration
public 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
|
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 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
|
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
.