Show / Hide Table of Contents

Class ConsensusReactor

A manager class for starting network and joining into consensus. Libplanet.Net.Consensus.ConsensusReactor.ConsensusContext

Inheritance
Object
ConsensusReactor
Implements
IReactor
IDisposable
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Namespace: Libplanet.Net.Consensus
Assembly: Libplanet.Net.dll
Syntax
public class ConsensusReactor : IReactor, IDisposable

Constructors

| Improve this Doc View Source

ConsensusReactor(ITransport, BlockChain, PrivateKey, ImmutableList<BoundPeer>, ImmutableList<BoundPeer>, TimeSpan, ContextTimeoutOption)

Initializes a new instance of the ConsensusReactor class.

Declaration
public ConsensusReactor(ITransport consensusTransport, BlockChain blockChain, PrivateKey privateKey, ImmutableList<BoundPeer> validatorPeers, ImmutableList<BoundPeer> seedPeers, TimeSpan newHeightDelay, ContextTimeoutOption contextTimeoutOption)
Parameters
Type Name Description
ITransport consensusTransport

An ITransport for sending the ConsensusMsgs to validators.

BlockChain blockChain

A blockchain that will be committed, which will be voted by consensus, and used for proposing a block.

PrivateKey privateKey

A PrivateKey for using in signing a block, message.

ImmutableList<BoundPeer> validatorPeers

A list of validator's BoundPeer, including itself.

ImmutableList<BoundPeer> seedPeers

A list of seed's BoundPeer.

TimeSpan newHeightDelay

A time delay in starting the consensus for the next height block.

ContextTimeoutOption contextTimeoutOption

A ContextTimeoutOption for configuring a timeout for each Step.

Properties

| Improve this Doc View Source

Height

The index of block that ConsensusContext is watching. The value can be changed by starting a consensus or appending a block.

Declaration
public long Height { get; }
Property Value
Type Description
Int64

If NewHeight(Int64) or Libplanet.Net.Consensus.ConsensusContext.OnTipChanged(System.Object,System.ValueTuple{Libplanet.Blocks.Block,Libplanet.Blocks.Block}) is called before, returns current working height, otherwise returns -1.

See Also
NewHeight(Int64)
Libplanet.Net.Consensus.ConsensusContext.OnTipChanged(System.Object,System.ValueTuple{Libplanet.Blocks.Block,Libplanet.Blocks.Block})
| Improve this Doc View Source

Running

Whether this ConsensusReactor is running.

Declaration
public bool Running { get; }
Property Value
Type Description
Boolean
| Improve this Doc View Source

Validators

An IEnumerable<T> of the validators.

Declaration
public IReadOnlyList<BoundPeer> Validators { get; }
Property Value
Type Description
IReadOnlyList<BoundPeer>

Methods

| Improve this Doc View Source

Dispose()

Declaration
public void Dispose()
| Improve this Doc View Source

StartAsync(CancellationToken)

Starts the instance and joins into consensus.

Declaration
public async Task StartAsync(CancellationToken cancellationToken)
Parameters
Type Name Description
CancellationToken cancellationToken

A cancellation token used to propagate notification that this operation should be canceled.

Returns
Type Description
Task

Returns the StartAsync(CancellationToken).

| Improve this Doc View Source

StopAsync(CancellationToken)

Stops the instance and consensus.

Declaration
public async Task StopAsync(CancellationToken cancellationToken)
Parameters
Type Name Description
CancellationToken cancellationToken

A cancellation Token.

Returns
Type Description
Task

Returns the StopAsync(TimeSpan, CancellationToken).

| Improve this Doc View Source

ToString()

Returns a summary of current consensus status in JSON-formatted string.

Declaration
public override string ToString()
Returns
Type Description
String

Returns a summary in JSON-formatted string.

Overrides
Object.ToString()

Implements

IReactor
System.IDisposable
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium