Class DelayedRenderer<T>
Decorates an IRenderer<T> instance and delays the events until blocks are confirmed the certain number of blocks. When blocks are recognized the delayed events relevant to these blocks are relayed to the decorated IRenderer<T>.
Implements
Namespace: Libplanet.Blockchain.Renderers
Assembly: Libplanet.dll
Syntax
public class DelayedRenderer<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. |
Remarks
Since IActionRenderer<T> is a subtype of IRenderer<T>, DelayedRenderer(IRenderer<T>, IStore, Int32) constructor can take an IActionRenderer<T> instance as well. However, even it takes an action renderer, action-level fine-grained events won't hear. For action renderers, please use DelayedActionRenderer<T> instead.
Examples
IStore store = GetStore();
IRenderer<ExampleAction> renderer = new SomeRenderer();
// Wraps the renderer with DelayedRenderer; the SomeRenderer instance becomes to receive
// event messages only after the relevent blocks are confirmed by 3+ blocks.
renderer = new DelayedRenderer<ExampleAction>(renderer, store, confirmations: 3);
// You must pass the same store to the BlockChain<T>() constructor:
var chain = new BlockChain<ExampleAction>(..., store: store, renderers: new[] { renderer });
Constructors
| Improve this Doc View SourceDelayedRenderer(IRenderer<T>, IStore, Int32)
Creates a new DelayedRenderer<T> instance decorating the given
renderer
.
Declaration
public DelayedRenderer(IRenderer<T> renderer, IStore store, int confirmations)
Parameters
Type | Name | Description |
---|---|---|
IRenderer<T> | renderer | The renderer to decorate which has the actual implementations and receives delayed events. |
IStore | store | The same store to what BlockChain<T> uses. |
Int32 | confirmations | The required number of confirmations to recognize a block.
It must be greater than zero (note that zero |
Properties
| Improve this Doc View SourceConfirmations
The required number of confirmations to recognize a block.
For example, the required confirmations are 2, the block #N is recognized after the block #N+1 and the block #N+2 are discovered.
Declaration
public int Confirmations { get; }
Property Value
Type | Description |
---|---|
Int32 |
Confirmed
Declaration
protected ConcurrentDictionary<HashDigest<SHA256>, uint> Confirmed { get; }
Property Value
Type | Description |
---|---|
ConcurrentDictionary<HashDigest<SHA256>, UInt32> |
Logger
The logger to record internal state changes.
Declaration
protected ILogger Logger { get; }
Property Value
Type | Description |
---|---|
ILogger |
Renderer
The inner renderer which has the actual implementations and receives delayed events.
Declaration
public IRenderer<T> Renderer { get; }
Property Value
Type | Description |
---|---|
IRenderer<T> |
Store
The same store to what BlockChain<T> uses.
Declaration
public IStore Store { get; }
Property Value
Type | Description |
---|---|
IStore |
Tip
The recognized topmost block. If not enough blocks are discovered yet,
this property can be null
.
Declaration
public Block<T> Tip { get; }
Property Value
Type | Description |
---|---|
Block<T> |
Methods
| Improve this Doc View SourceDiscoverBlock(Block<T>, Block<T>)
Declaration
protected void DiscoverBlock(Block<T> oldTip, Block<T> newTip)
Parameters
Type | Name | Description |
---|---|---|
Block<T> | oldTip | |
Block<T> | newTip |
OnTipChanged(Block<T>, Block<T>, Block<T>)
The callback method which is invoked when the new Tip is recognized and changed.
Declaration
protected virtual void OnTipChanged(Block<T> oldTip, Block<T> newTip, Block<T> branchpoint)
Parameters
Type | Name | Description |
---|---|---|
Block<T> | oldTip | The previously recognized topmost block. |
Block<T> | newTip | The topmost block recognized this time. |
Block<T> | branchpoint | A branchpoint between |
RenderBlock(Block<T>, Block<T>)
Declaration
public virtual void RenderBlock(Block<T> oldTip, Block<T> newTip)
Parameters
Type | Name | Description |
---|---|---|
Block<T> | oldTip | |
Block<T> | newTip |
RenderReorg(Block<T>, Block<T>, Block<T>)
Declaration
public virtual void RenderReorg(Block<T> oldTip, Block<T> newTip, Block<T> branchpoint)
Parameters
Type | Name | Description |
---|---|---|
Block<T> | oldTip | |
Block<T> | newTip | |
Block<T> | branchpoint |
RenderReorgEnd(Block<T>, Block<T>, Block<T>)
Declaration
public virtual void RenderReorgEnd(Block<T> oldTip, Block<T> newTip, Block<T> branchpoint)
Parameters
Type | Name | Description |
---|---|---|
Block<T> | oldTip | |
Block<T> | newTip | |
Block<T> | branchpoint |