Interface IRenderer<T>
Listens state changes on a BlockChain<T>.
Usually, implementations of this interface purpose to update the in-memory game states (if exist), or send a signal to the UI thread (usually the main thread) so that the graphics on the display is redrawn.
The invocation order of methods for each Block<T> are:
- RenderReorg(Block<T>, Block<T>, Block<T>) (one time)
- RenderBlock(Block<T>, Block<T>) (one time)
- RenderReorgEnd(Block<T>, Block<T>, Block<T>) (one time)
Namespace: Libplanet.Blockchain.Renderers
Assembly: Libplanet.dll
Syntax
public interface IRenderer<T>
where T : IAction, new()
Type Parameters
Name | Description |
---|---|
T | An IAction type. It should match to BlockChain<T>'s type parameter. |
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
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
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
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
.