![]() |
Bitcoin ABC
0.22.15
P2P Digital Currency
|
#include <processor.h>
Public Member Functions | |
VoteRecord (bool accepted) | |
VoteRecord (const VoteRecord &other) | |
Copy semantic. More... | |
bool | isAccepted () const |
Vote accounting facilities. More... | |
uint16_t | getConfidence () const |
bool | hasFinalized () const |
bool | registerVote (NodeId nodeid, uint32_t error) |
Register a new vote for an item and update confidence accordingly. More... | |
bool | registerPoll () const |
Register that a request is being made regarding that item. More... | |
bool | shouldPoll () const |
Return if this item is in condition to be polled at the moment. More... | |
void | clearInflightRequest (uint8_t count=1) |
Clear count inflight requests. More... | |
Private Member Functions | |
bool | addNodeToQuorum (NodeId nodeid) |
Add the node to the quorum. More... | |
Private Attributes | |
uint16_t | confidence = 0 |
uint8_t | votes = 0 |
uint8_t | consider = 0 |
std::atomic< uint8_t > | inflight {0} |
const uint32_t | seed = 0 |
uint32_t | successfulVotes = 0 |
std::array< uint16_t, 8 > | nodeFilter {{0, 0, 0, 0, 0, 0, 0, 0}} |
Vote history.
Definition at line 74 of file processor.h.
|
inlineexplicit |
Definition at line 97 of file processor.h.
|
inline |
Copy semantic.
Definition at line 102 of file processor.h.
|
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 80 of file processor.cpp.
|
inline |
Clear count
inflight requests.
Definition at line 139 of file processor.h.
|
inline |
|
inline |
Definition at line 114 of file processor.h.
|
inline |
Vote accounting facilities.
Definition at line 111 of file processor.h.
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 vote_records. It's not a problem as it is made thread safe.
Definition at line 111 of file processor.cpp.
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 32 of file processor.cpp.
|
inline |
Return if this item is in condition to be polled at the moment.
Definition at line 134 of file processor.h.
|
private |
Definition at line 78 of file processor.h.
|
private |
Definition at line 83 of file processor.h.
|
mutableprivate |
Definition at line 85 of file processor.h.
|
private |
Definition at line 94 of file processor.h.
|
private |
Definition at line 88 of file processor.h.
|
private |
Definition at line 91 of file processor.h.
|
private |
Definition at line 81 of file processor.h.