Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
avalanche::VoteRecord Struct Reference

Vote history. More...

#include <voterecord.h>

Inheritance diagram for avalanche::VoteRecord:
[legend]

Public Member Functions

 VoteRecord (bool accepted)
 
 VoteRecord (const VoteRecord &other)
 Copy semantic.
 
bool isAccepted () const
 Vote accounting facilities.
 
uint16_t getConfidence () const
 
bool hasFinalized () const
 
bool isStale (uint32_t staleThreshold=AVALANCHE_VOTE_STALE_THRESHOLD, uint32_t staleFactor=AVALANCHE_VOTE_STALE_FACTOR) const
 
bool registerVote (NodeId nodeid, uint32_t error)
 Register a new vote for an item and update confidence accordingly.
 
bool registerPoll () const
 Register that a request is being made regarding that item.
 
bool shouldPoll () const
 Return if this item is in condition to be polled at the moment.
 
void clearInflightRequest (uint8_t count=1)
 Clear count inflight requests.
 

Private Member Functions

bool addNodeToQuorum (NodeId nodeid)
 Add the node to the quorum.
 

Private Attributes

uint16_t confidence = 0
 
uint8_t votes = 0
 
uint8_t consider = 0
 
std::atomic< uint8_tinflight {0}
 
const uint32_t seed = 0
 
uint32_t successfulVotes = 0
 
std::array< uint16_t, 8 > nodeFilter {{0, 0, 0, 0, 0, 0, 0, 0}}
 

Friends

struct ::avalanche::TestVoteRecord
 

Detailed Description

Vote history.

Definition at line 49 of file voterecord.h.

Constructor & Destructor Documentation

◆ VoteRecord() [1/2]

avalanche::VoteRecord::VoteRecord ( bool  accepted)
inlineexplicit

Definition at line 72 of file voterecord.h.

◆ VoteRecord() [2/2]

avalanche::VoteRecord::VoteRecord ( const VoteRecord other)
inline

Copy semantic.

Definition at line 77 of file voterecord.h.

Member Function Documentation

◆ addNodeToQuorum()

bool avalanche::VoteRecord::addNodeToQuorum ( NodeId  nodeid)
private

Add the node to the quorum.

Returns true if the node was added, false if the node already was in the quorum.

Check if the node is in the filter.

Add the node which just voted to the filter.

Definition at line 61 of file voterecord.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearInflightRequest()

void avalanche::VoteRecord::clearInflightRequest ( uint8_t  count = 1)
inline

Clear count inflight requests.

Definition at line 120 of file voterecord.h.

Here is the caller graph for this function:

◆ getConfidence()

uint16_t avalanche::VoteRecord::getConfidence ( ) const
inline

Definition at line 88 of file voterecord.h.

Here is the caller graph for this function:

◆ hasFinalized()

bool avalanche::VoteRecord::hasFinalized ( ) const
inline

Definition at line 89 of file voterecord.h.

Here is the call graph for this function:

◆ isAccepted()

bool avalanche::VoteRecord::isAccepted ( ) const
inline

Vote accounting facilities.

Definition at line 86 of file voterecord.h.

Here is the caller graph for this function:

◆ isStale()

bool avalanche::VoteRecord::isStale ( uint32_t  staleThreshold = AVALANCHE_VOTE_STALE_THRESHOLD,
uint32_t  staleFactor = AVALANCHE_VOTE_STALE_FACTOR 
) const
inline

Definition at line 93 of file voterecord.h.

Here is the call graph for this function:

◆ registerPoll()

bool avalanche::VoteRecord::registerPoll ( ) const

Register that a request is being made regarding that item.

The method is made const so that it can be accessed via a read only view of blockVoteRecords. It's not a problem as it is made thread safe.

Definition at line 87 of file voterecord.cpp.

Here is the call graph for this function:

◆ registerVote()

bool avalanche::VoteRecord::registerVote ( NodeId  nodeid,
uint32_t  error 
)

Register a new vote for an item and update confidence accordingly.

Returns true if the acceptance or finalization state changed.

The result of the vote is determined from the error code. If the error code is 0, there is no error and therefore the vote is yes. If there is an error, we check the most significant bit to decide if the vote is a no (for instance, the block is invalid) or is the vote inconclusive (for instance, the queried node does not have the block yet).

We compute the number of yes and/or no votes as follow:

votes: 1010 consider: 1100

yes votes: 1000 using votes & consider no votes: 0100 using ~votes & consider

Definition at line 13 of file voterecord.cpp.

Here is the call graph for this function:

◆ shouldPoll()

bool avalanche::VoteRecord::shouldPoll ( ) const
inline

Return if this item is in condition to be polled at the moment.

Definition at line 115 of file voterecord.h.

Friends And Related Symbol Documentation

◆ ::avalanche::TestVoteRecord

Definition at line 130 of file voterecord.h.

Member Data Documentation

◆ confidence

uint16_t avalanche::VoteRecord::confidence = 0
private

Definition at line 53 of file voterecord.h.

◆ consider

uint8_t avalanche::VoteRecord::consider = 0
private

Definition at line 58 of file voterecord.h.

◆ inflight

std::atomic<uint8_t> avalanche::VoteRecord::inflight {0}
mutableprivate

Definition at line 60 of file voterecord.h.

◆ nodeFilter

std::array<uint16_t, 8> avalanche::VoteRecord::nodeFilter {{0, 0, 0, 0, 0, 0, 0, 0}}
private

Definition at line 69 of file voterecord.h.

◆ seed

const uint32_t avalanche::VoteRecord::seed = 0
private

Definition at line 63 of file voterecord.h.

◆ successfulVotes

uint32_t avalanche::VoteRecord::successfulVotes = 0
private

Definition at line 66 of file voterecord.h.

◆ votes

uint8_t avalanche::VoteRecord::votes = 0
private

Definition at line 56 of file voterecord.h.


The documentation for this struct was generated from the following files: