Show / Hide Table of Contents

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.

Inheritance
Object
AnonymousRenderer<T>
AnonymousActionRenderer<T>
Implements
IRenderer<T>
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Libplanet.Blockchain.Renderers
Assembly: Libplanet.dll
Syntax
public class AnonymousRenderer<T> : 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 Source

BlockRenderer

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
Action<Block<T>, Block<T>>
| Improve this Doc View Source

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
Action<Block<T>, Block<T>, Block<T>>
| Improve this Doc View Source

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
Action<Block<T>, Block<T>, Block<T>>

Methods

| Improve this Doc View Source

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

| Improve this Doc View Source

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 oldTip and newTip.

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.

| Improve this Doc View Source

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 oldTip and newTip.

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.

Implements

IRenderer<T>
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2021 Planetarium