Class VoteSet
Inherited Members
Namespace: Libplanet.Net.Consensus
Assembly: Libplanet.Net.dll
Syntax
public class VoteSet
Constructors
| Improve this Doc View SourceVoteSet(Int64, Int32, VoteFlag, ValidatorSet)
Declaration
public VoteSet(long height, int round, VoteFlag voteType, ValidatorSet validatorSet)
Parameters
Type | Name | Description |
---|---|---|
Int64 | height | |
Int32 | round | |
VoteFlag | voteType | |
ValidatorSet | validatorSet |
Properties
| Improve this Doc View SourceCount
Count of the canonical Votes.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 |
Sum
Declaration
public BigInteger Sum { get; }
Property Value
Type | Description |
---|---|
BigInteger |
TotalCount
Count of the all Votes.
Declaration
public int TotalCount { get; }
Property Value
Type | Description |
---|---|
Int32 |
Validators
Declaration
public IEnumerable<Validator> Validators { get; }
Property Value
Type | Description |
---|---|
IEnumerable<Validator> |
Methods
| Improve this Doc View SourceBitArray()
Declaration
public bool[] BitArray()
Returns
Type | Description |
---|---|
Boolean[] |
BitArrayByBlockHash(BlockHash)
Declaration
public bool[] BitArrayByBlockHash(BlockHash blockHash)
Parameters
Type | Name | Description |
---|---|---|
BlockHash | blockHash |
Returns
Type | Description |
---|---|
Boolean[] |
Contains(PublicKey, BlockHash)
Predicate indicates where the VoteSet have collected a vote with
given publicKey
and blockHash
.
Declaration
public bool Contains(PublicKey publicKey, BlockHash blockHash)
Parameters
Type | Name | Description |
---|---|---|
PublicKey | publicKey | |
BlockHash | blockHash |
Returns
Type | Description |
---|---|
Boolean | true when a vote with given params exits, else false. |
GetAllVotes()
Gets all collected Votes.
Declaration
public IEnumerable<Vote> GetAllVotes()
Returns
Type | Description |
---|---|
IEnumerable<Vote> | IEnumerable<T> of Vote. |
GetByPublicKey(PublicKey)
Gets the Vote signed by given publicKey
.
If given validator has conflicting votes, returns "canonical" Vote.
Declaration
public Vote GetByPublicKey(PublicKey publicKey)
Parameters
Type | Name | Description |
---|---|---|
PublicKey | publicKey |
Returns
Type | Description |
---|---|
Vote | A Vote signed by given |
Exceptions
Type | Condition |
---|---|
KeyNotFoundException | Thrown when there's no Vote
signed by given |
GetVote(PublicKey, BlockHash)
Gets a Vote signed by publicKey
and of hash
blockHash
.
Declaration
public Vote GetVote(PublicKey publicKey, BlockHash blockHash)
Parameters
Type | Name | Description |
---|---|---|
PublicKey | publicKey | |
BlockHash | blockHash |
Returns
Type | Description |
---|---|
Vote | A Vote signed by |
GetVotes(BlockHash)
Gets all collected Votes that voted to block with hash
blockHash
.
Declaration
public IEnumerable<Vote> GetVotes(BlockHash blockHash)
Parameters
Type | Name | Description |
---|---|---|
BlockHash | blockHash |
Returns
Type | Description |
---|---|
IEnumerable<Vote> | IEnumerable<T> of Vote. |
HasAll()
Predicate which returns true when collected all Votes. Else, return false.
Declaration
public bool HasAll()
Returns
Type | Description |
---|---|
Boolean | true when collected all Votes. Else, false. |
HasOneThirdsAny()
If there is a +1/3 majority for any BlockHash, return true. Else, return false.
Declaration
public bool HasOneThirdsAny()
Returns
Type | Description |
---|---|
Boolean | true if +1/3 majority exists, else false. |
HasTwoThirdsAny()
If there is a +2/3 majority for any BlockHash, return true. Else, return false.
Declaration
public bool HasTwoThirdsAny()
Returns
Type | Description |
---|---|
Boolean | true if +2/3 majority exists, else false. |
HasTwoThirdsMajority()
If there is a +2/3 majority for certain BlockHash, return true. Else, return false.
Declaration
public bool HasTwoThirdsMajority()
Returns
Type | Description |
---|---|
Boolean | true if +2/3 majority exists, else false. |
IsCommit()
A predicate indicates whether the VoteSet collected +2/3 majority commits.
Declaration
public bool IsCommit()
Returns
Type | Description |
---|---|
Boolean | true if the VoteSet collected +2/3 majority commits, else false. |
List()
Declaration
public List<Vote> List()
Returns
Type | Description |
---|---|
List<Vote> |
MappedList()
Returns a copy of the list of Votes stored by the VoteSet. If failed to collect Vote from certain peer, fill it with nil Vote.
Declaration
public List<Vote> MappedList()
Returns
Type | Description |
---|---|
List<Vote> | A copy of the list of Votes stored by the VoteSet. If failed to collect Vote from certain peer, fill it with nil Vote. |
Exceptions
Type | Condition |
---|---|
NullReferenceException | Thrown when there are no +2/3 majority Votes. |
SetPeerMaj23(Maj23)
If a peer claims that it has 2/3 majority for given BlockHash, modify state by calling this method.
Declaration
public bool SetPeerMaj23(Maj23 maj23)
Parameters
Type | Name | Description |
---|---|---|
Maj23 | maj23 | A Maj23 received by other validator. |
Returns
Type | Description |
---|---|
Boolean | true when given |
Remarks
if there are too many peers, or too much peer churn, this can cause memory issues.
Exceptions
Type | Condition |
---|---|
InvalidMaj23Exception | Thrown when given |
ToBlockCommit()
Create a BlockCommit instance if VoteSet has +2/3 majority commits.
Declaration
public BlockCommit ToBlockCommit()
Returns
Type | Description |
---|---|
BlockCommit | A BlockCommit instance made by collected commits. If failed to collect +2/3 majority commits, return null. |
TwoThirdsMajority(out BlockHash)
If there is a +2/3 majority for certain BlockHash, return BlockHash and true. Else, return the langword_csharp_default BlockHash and false.
Declaration
public bool TwoThirdsMajority(out BlockHash blockHash)
Parameters
Type | Name | Description |
---|---|---|
BlockHash | blockHash | BlockHash of the +2/3 majority vote. If not exists, it will have langword_csharp_default. |
Returns
Type | Description |
---|---|
Boolean | true if +2/3 majority exists, else false. |