Show / Hide Table of Contents

Class ConsensusContext

A class that maintains the states of a Context for block indices now in consensus.

Inheritance
Object
ConsensusContext
Implements
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 ConsensusContext : IDisposable

Constructors

| Improve this Doc View Source

ConsensusContext(ConsensusContext.DelegateBroadcastMessage, BlockChain, PrivateKey, TimeSpan, ContextTimeoutOption)

Initializes a new instance of the ConsensusContext class.

Declaration
public ConsensusContext(ConsensusContext.DelegateBroadcastMessage broadcastMessage, BlockChain blockChain, PrivateKey privateKey, TimeSpan newHeightDelay, ContextTimeoutOption contextTimeoutOption)
Parameters
Type Name Description
ConsensusContext.DelegateBroadcastMessage broadcastMessage

A delegate method that will broadcasting given ConsensusMsg 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 signing message and blocks.

TimeSpan newHeightDelay

A time delay in starting the consensus for the next height block. Libplanet.Net.Consensus.ConsensusContext.OnTipChanged(System.Object,System.ValueTuple{Libplanet.Blocks.Block,Libplanet.Blocks.Block})

ContextTimeoutOption contextTimeoutOption

A ContextTimeoutOption for configuring a timeout for each Step.

Properties

| Improve this Doc View Source

BroadcastMessage

A class that maintains the states of a Context for block indices now in consensus.

Declaration
public ConsensusContext.DelegateBroadcastMessage BroadcastMessage { get; }
Property Value
Type Description
ConsensusContext.DelegateBroadcastMessage
| 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

Round

A current round of Context in current Height.

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

If there is Context for Height returns the round of current Context, or otherwise returns -1.

| Improve this Doc View Source

Step

The current step of Context in current Height.

Declaration
public Step Step { get; }
Property Value
Type Description
Step

If there is Context for Height returns the step of current Context, or otherwise returns Null.

Methods

| Improve this Doc View Source

Dispose()

A class that maintains the states of a Context for block indices now in consensus.

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

HandleMessage(ConsensusMsg)

Handles a received ConsensusMsg by either dispatching it to the right Context or discarding it.

In particular, this discards consensusMessage with Height less than Height. Otherwise, given consensusMessage is passed on to a Context with Height the same as Height of consensusMessage. If there is no such Context, then a new Context is created for the dispatch.

Declaration
public bool HandleMessage(ConsensusMsg consensusMessage)
Parameters
Type Name Description
ConsensusMsg consensusMessage

The ConsensusMsg received from any validator.

Returns
Type Description
Boolean

true if consensusMessage is dispatched to a Context, false otherwise.

| Improve this Doc View Source

NewHeight(Int64)

Starts a new Context for given height.

Declaration
public void NewHeight(long height)
Parameters
Type Name Description
Int64 height

The height of a new Context to start.

Remarks

The method is also called when the tip of the BlockChain is changed (i.e., committed, synchronized).

Exceptions
Type Condition
InvalidHeightIncreasingException

Thrown if given height is less than or equal to Height.

| Improve this Doc View Source

ToString()

Returns the summary for ConsensusContext.

Declaration
public override string ToString()
Returns
Type Description
String

Returns the current height Context. if there's no instance of Context for current height, returns "No context".

Overrides
Object.ToString()

Implements

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