Show / Hide Table of Contents

Class ValidatorSet

A wrapper class for a List<T> of Validators. This standardizes the ordering of validators by Address.

Inheritance
Object
ValidatorSet
Implements
IEquatable<ValidatorSet>
Bencodex.IBencodable
Inherited Members
Object.Equals(Object, Object)
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Libplanet.Types.Consensus
Assembly: Libplanet.Types.dll
Syntax
public class ValidatorSet : IEquatable<ValidatorSet>, IBencodable

Constructors

| Improve this Doc View Source

ValidatorSet()

Creates an instance of an empty ValidatorSet. to Validators.

Declaration
public ValidatorSet()
| Improve this Doc View Source

ValidatorSet(IValue)

A wrapper class for a List<T> of Validators. This standardizes the ordering of validators by Address.

Declaration
public ValidatorSet(IValue bencoded)
Parameters
Type Name Description
Bencodex.Types.IValue bencoded
| Improve this Doc View Source

ValidatorSet(List<Validator>)

Creates an instance of ValidatorSet. Given validators is ordered internally by Address before getting assigned to Validators.

Declaration
public ValidatorSet(List<Validator> validators)
Parameters
Type Name Description
List<Validator> validators

The List<T> of validators to use.

Exceptions
Type Condition
ArgumentException

Thrown when one of the following is true:

  • There is a duplicate among PublicKeys for validators.
  • There is a Validator with zero power.

Properties

| Improve this Doc View Source

Bencoded

A wrapper class for a List<T> of Validators. This standardizes the ordering of validators by Address.

Declaration
public IValue Bencoded { get; }
Property Value
Type Description
Bencodex.Types.IValue
| Improve this Doc View Source

Item[Int32]

Gets the validator at given index.

Declaration
public Validator this[int index] { get; }
Parameters
Type Name Description
Int32 index

The index to search.

Property Value
Type Description
Validator

The validator at given index.

| Improve this Doc View Source

OneThirdCount

The one third of validator count, rounded down.

Declaration
public int OneThirdCount { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

OneThirdPower

The one third of validator total power, rounded down.

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

PublicKeys

An ImmutableList<T> of public keys of validators. This is guaranteed to be ordered by Address.

Declaration
public ImmutableList<PublicKey> PublicKeys { get; }
Property Value
Type Description
ImmutableList<PublicKey>
| Improve this Doc View Source

TotalCount

The total number of validators.

Declaration
public int TotalCount { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

TotalPower

The total power of validators.

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

TwoThirdsCount

The two thirds of validator count, rounded down.

Declaration
public int TwoThirdsCount { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

TwoThirdsPower

The two thirds of validator total power, rounded down.

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

Validators

An ImmutableList<T> of validators. This is guaranteed to be ordered by Address.

Declaration
public ImmutableList<Validator> Validators { get; }
Property Value
Type Description
ImmutableList<Validator>

Methods

| Improve this Doc View Source

Contains(Validator)

Checks if given validator is a member of ValidatorSet. Checks both of PublicKey and Power.

Declaration
public bool Contains(Validator validator)
Parameters
Type Name Description
Validator validator

The Validator to check.

Returns
Type Description
Boolean

true if given validator is in Validators, false otherwise.

| Improve this Doc View Source

ContainsPublicKey(PublicKey)

Checks if given publicKey is a member of ValidatorSet.

Declaration
public bool ContainsPublicKey(PublicKey publicKey)
Parameters
Type Name Description
PublicKey publicKey

The PublicKey of the Validator to check.

Returns
Type Description
Boolean

true if given publicKey is in Validators, false otherwise.

| Improve this Doc View Source

Equals(ValidatorSet)

A wrapper class for a List<T> of Validators. This standardizes the ordering of validators by Address.

Declaration
public bool Equals(ValidatorSet other)
Parameters
Type Name Description
ValidatorSet other
Returns
Type Description
Boolean
| Improve this Doc View Source

Equals(Object)

A wrapper class for a List<T> of Validators. This standardizes the ordering of validators by Address.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
Object obj
Returns
Type Description
Boolean
Overrides
Object.Equals(Object)
| Improve this Doc View Source

FindIndex(PublicKey)

Gets the index of given publicKey.

Declaration
public int FindIndex(PublicKey publicKey)
Parameters
Type Name Description
PublicKey publicKey

The PublicKey to find index.

Returns
Type Description
Int32

The index of given publicKey.

| Improve this Doc View Source

GetHashCode()

A wrapper class for a List<T> of Validators. This standardizes the ordering of validators by Address.

Declaration
public override int GetHashCode()
Returns
Type Description
Int32
Overrides
Object.GetHashCode()
| Improve this Doc View Source

GetProposer(Int64, Int32)

Gets the proposer for a given context.

Declaration
public Validator GetProposer(long height, int round)
Parameters
Type Name Description
Int64 height

The height of the context under consideration.

Int32 round

The round of the context under consideration.

Returns
Type Description
Validator

A Validator deterministically chosen from Validators, height, and round.

Exceptions
Type Condition
InvalidOperationException

Thrown when Validators is empty.

| Improve this Doc View Source

GetValidator(PublicKey)

A wrapper class for a List<T> of Validators. This standardizes the ordering of validators by Address.

Declaration
public Validator GetValidator(PublicKey publicKey)
Parameters
Type Name Description
PublicKey publicKey
Returns
Type Description
Validator
| Improve this Doc View Source

GetValidators(IEnumerable<PublicKey>)

A wrapper class for a List<T> of Validators. This standardizes the ordering of validators by Address.

Declaration
public ImmutableList<Validator> GetValidators(IEnumerable<PublicKey> publicKeys)
Parameters
Type Name Description
IEnumerable<PublicKey> publicKeys
Returns
Type Description
ImmutableList<Validator>
| Improve this Doc View Source

GetValidatorsPower(List<PublicKey>)

A wrapper class for a List<T> of Validators. This standardizes the ordering of validators by Address.

Declaration
public BigInteger GetValidatorsPower(List<PublicKey> publicKeys)
Parameters
Type Name Description
List<PublicKey> publicKeys
Returns
Type Description
BigInteger
| Improve this Doc View Source

Update(Validator)

Creates a new ValidatorSet that has been updated with given validator according to the following rule:

  • If validator's power is zero, the Validator with the same PublicKey is removed, if it exists. If no matching Validator is found, no change is made.
  • If validator's power is positive, the Validator with the same PublicKey is overwritten, if it exists. If no matching Validator is found, validator is added to the set.
Declaration
[Pure]
public ValidatorSet Update(Validator validator)
Parameters
Type Name Description
Validator validator

The Validator to update.

Returns
Type Description
ValidatorSet

New ValidatorSet updated with given validator.

| Improve this Doc View Source

ValidateBlockCommitValidators(BlockCommit)

Checks whether Votes is ordered by Address of each ValidatorPublicKey.

Declaration
public bool ValidateBlockCommitValidators(BlockCommit blockCommit)
Parameters
Type Name Description
BlockCommit blockCommit

The BlockCommit to check.

Returns
Type Description
Boolean

true if the Votes is ordered, false otherwise.

Implements

System.IEquatable<T>
Bencodex.IBencodable
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium