Class ValidatorSet
Inheritance
Implements
Namespace: Libplanet.Types.Consensus
Assembly: Libplanet.Types.dll
Syntax
public class ValidatorSet : IEquatable<ValidatorSet>
Constructors
| Improve this Doc View SourceValidatorSet()
Creates an instance of an empty ValidatorSet. to Validators.
Declaration
public ValidatorSet()
ValidatorSet(Bencodex.Types.IValue)
Declaration
public ValidatorSet(Bencodex.Types.IValue bencoded)
Parameters
| Type | Name | Description |
|---|---|---|
| Bencodex.Types.IValue | bencoded |
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 |
Properties
| Improve this Doc View SourceBencoded
Declaration
public Bencodex.Types.IValue Bencoded { get; }
Property Value
| Type | Description |
|---|---|
| Bencodex.Types.IValue |
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 |
OneThirdCount
The one third of validator count, rounded down.
Declaration
public int OneThirdCount { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
OneThirdPower
The one third of validator total power, rounded down.
Declaration
public BigInteger OneThirdPower { get; }
Property Value
| Type | Description |
|---|---|
| BigInteger |
PublicKeys
An
Declaration
public ImmutableList<PublicKey> PublicKeys { get; }
Property Value
| Type | Description |
|---|---|
| ImmutableList<PublicKey> |
TotalCount
The total number of validators.
Declaration
public int TotalCount { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
TotalPower
The total power of validators.
Declaration
public BigInteger TotalPower { get; }
Property Value
| Type | Description |
|---|---|
| BigInteger |
TwoThirdsCount
The two thirds of validator count, rounded down.
Declaration
public int TwoThirdsCount { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
TwoThirdsPower
The two thirds of validator total power, rounded down.
Declaration
public BigInteger TwoThirdsPower { get; }
Property Value
| Type | Description |
|---|---|
| BigInteger |
Validators
An
Declaration
public ImmutableList<Validator> Validators { get; }
Property Value
| Type | Description |
|---|---|
| ImmutableList<Validator> |
Methods
| Improve this Doc View SourceContains(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 |
ContainsPublicKey(PublicKey)
Checks if given publicKey is a member of ValidatorSet.
Declaration
public bool ContainsPublicKey(PublicKey publicKey)
Parameters
| Type | Name | Description |
|---|---|---|
| PublicKey | publicKey |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if given |
Equals(ValidatorSet)
Declaration
public bool Equals(ValidatorSet other)
Parameters
| Type | Name | Description |
|---|---|---|
| ValidatorSet | other |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Equals(Nullable<Object>)
Declaration
public override bool Equals(object? obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Nullable<System.Object> | obj |
Returns
| Type | Description |
|---|---|
| System.Boolean |
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 |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 |
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, |
GetValidator(PublicKey)
Declaration
public Validator GetValidator(PublicKey publicKey)
Parameters
| Type | Name | Description |
|---|---|---|
| PublicKey | publicKey |
Returns
| Type | Description |
|---|---|
| Validator |
GetValidators(IEnumerable<PublicKey>)
Declaration
public ImmutableList<Validator> GetValidators(IEnumerable<PublicKey> publicKeys)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<PublicKey> | publicKeys |
Returns
| Type | Description |
|---|---|
| ImmutableList<Validator> |
GetValidatorsPower(List<PublicKey>)
Declaration
public BigInteger GetValidatorsPower(List<PublicKey> publicKeys)
Parameters
| Type | Name | Description |
|---|---|---|
| List<PublicKey> | publicKeys |
Returns
| Type | Description |
|---|---|
| BigInteger |
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,validatoris 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 |
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 void ValidateBlockCommitValidators(BlockCommit blockCommit)
Parameters
| Type | Name | Description |
|---|---|---|
| BlockCommit | blockCommit | The BlockCommit to check. |
Remarks
If ValidatorPower is null, power check is ignored.
Exceptions
| Type | Condition |
|---|---|
| InvalidBlockCommitException | Thrown when validators from
|
| InvalidBlockCommitException | Thrown when vote's power in the
|
ValidateLegacyBlockCommitValidators(BlockCommit)
Checks whether Votes is ordered by Address of each ValidatorPublicKey, and ValidatorPower equals to the one recorded in the chain states.
Declaration
public void ValidateLegacyBlockCommitValidators(BlockCommit blockCommit)
Parameters
| Type | Name | Description |
|---|---|---|
| BlockCommit | blockCommit | The BlockCommit to check. |
Remarks
If ValidatorPower is null, power check is ignored.
Exceptions
| Type | Condition |
|---|---|
| InvalidBlockCommitException | Thrown when some votes in the
|
| InvalidBlockCommitException | Thrown when public key of validators from
|