Show / Hide Table of Contents

Class ValidatorSet

A wrapper class for a of Validators. This standardizes the ordering of validators by Address.

Inheritance
System.Object
ValidatorSet
Implements
IBencodable
Namespace: Libplanet.Types.Consensus
Assembly: Libplanet.Types.dll
Syntax
public class ValidatorSet : IEquatable<ValidatorSet>

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(Bencodex.Types.IValue)

A wrapper class for a of Validators. This standardizes the ordering of validators by Address.

Declaration
public ValidatorSet(Bencodex.Types.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 of validators to use.

Properties

| Improve this Doc View Source

Bencoded

A wrapper class for a of Validators. This standardizes the ordering of validators by Address.

Declaration
public Bencodex.Types.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
System.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
System.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 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
System.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
System.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 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
System.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
System.Boolean

true if given publicKey is in Validators, false otherwise.

| Improve this Doc View Source

Equals(ValidatorSet)

A wrapper class for a 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
System.Boolean
| Improve this Doc View Source

Equals(Nullable<Object>)

A wrapper class for a of Validators. This standardizes the ordering of validators by Address.

Declaration
public override bool Equals(object? obj)
Parameters
Type Name Description
System.Nullable<System.Object> obj
Returns
Type Description
System.Boolean
| 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
System.Int32

The index of given publicKey.

| Improve this Doc View Source

GetHashCode()

A wrapper class for a of Validators. This standardizes the ordering of validators by Address.

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32
| 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
System.Int64 height

The height of the context under consideration.

System.Int32 round

The round of the context under consideration.

Returns
Type Description
Validator

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

| Improve this Doc View Source

GetValidator(PublicKey)

A wrapper class for a 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 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 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
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, and ValidatorPower equals to the one recorded in the chain states.

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

The BlockCommit to check.

Returns
Type Description
System.Boolean

true if the Votes is ordered, false otherwise.

Remarks

If ValidatorPower is null, power check is ignored.

Implements

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