Show / Hide Table of Contents

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

Inheritance
Object
DelayedRenderer<T>
DelayedActionRenderer<T>
Implements
IRenderer<T>
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 Source

DelayedRenderer(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 confirmations mean nothing is delayed so that it is equivalent to the bare renderer). See also the Confirmations property.

Properties

| Improve this Doc View Source

Confirmations

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
| Improve this Doc View Source

Confirmed

Declaration
protected ConcurrentDictionary<HashDigest<SHA256>, uint> Confirmed { get; }
Property Value
Type Description
ConcurrentDictionary<HashDigest<SHA256>, UInt32>
| Improve this Doc View Source

Logger

The logger to record internal state changes.

Declaration
protected ILogger Logger { get; }
Property Value
Type Description
ILogger
| Improve this Doc View Source

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>
| Improve this Doc View Source

Store

The same store to what BlockChain<T> uses.

Declaration
public IStore Store { get; }
Property Value
Type Description
IStore
| Improve this Doc View Source

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 Source

DiscoverBlock(Block<T>, Block<T>)

Declaration
protected void DiscoverBlock(Block<T> oldTip, Block<T> newTip)
Parameters
Type Name Description
Block<T> oldTip
Block<T> newTip
| Improve this Doc View Source

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 oldTip and newTip if the tip change is a reorg. Otherwise null.

| Improve this Doc View Source

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
| Improve this Doc View Source

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
| Improve this Doc View Source

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

Implements

IRenderer<T>
  • Improve this Doc
  • View Source
Back to top Copyright © 2019–2020 Planetarium