Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche.h
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/** | /** | ||||
* Vote history. | * Vote history. | ||||
*/ | */ | ||||
struct VoteRecord { | struct VoteRecord { | ||||
private: | private: | ||||
// Historical record of votes. | // Historical record of votes. | ||||
uint8_t votes; | uint8_t votes = 0; | ||||
// Each bit indicate if the vote is to be considered. | // Each bit indicate if the vote is to be considered. | ||||
uint8_t consider; | uint8_t consider = 0; | ||||
// confidence's LSB bit is the result. Higher bits are actual confidence | // confidence's LSB bit is the result. Higher bits are actual confidence | ||||
// score. | // score. | ||||
uint16_t confidence; | uint16_t confidence = 0; | ||||
public: | public: | ||||
VoteRecord(bool accepted) : votes(0), consider(0), confidence(accepted) {} | VoteRecord(bool accepted) : confidence(accepted) {} | ||||
bool isAccepted() const { return confidence & 0x01; } | bool isAccepted() const { return confidence & 0x01; } | ||||
uint16_t getConfidence() const { return confidence >> 1; } | uint16_t getConfidence() const { return confidence >> 1; } | ||||
bool hasFinalized() const { | bool hasFinalized() const { | ||||
return getConfidence() >= AVALANCHE_FINALIZATION_SCORE; | return getConfidence() >= AVALANCHE_FINALIZATION_SCORE; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 229 Lines • Show Last 20 Lines |