Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/voterecord.h
Show All 11 Lines | |||||
#include <cstdint> | #include <cstdint> | ||||
/** | /** | ||||
* Finalization score. | * Finalization score. | ||||
*/ | */ | ||||
static constexpr int AVALANCHE_FINALIZATION_SCORE = 128; | static constexpr int AVALANCHE_FINALIZATION_SCORE = 128; | ||||
/** | /** | ||||
* Number of votes allowable before a record is rejected for being inconclusive | |||||
* for too long. | |||||
*/ | |||||
static constexpr int AVALANCHE_VOTE_INCONCLUSIVE_THRESHOLD = 1024; | |||||
/** | |||||
* How many inflight requests can exist for one item. | * How many inflight requests can exist for one item. | ||||
*/ | */ | ||||
static constexpr int AVALANCHE_MAX_INFLIGHT_POLL = 10; | static constexpr int AVALANCHE_MAX_INFLIGHT_POLL = 10; | ||||
namespace avalanche { | namespace avalanche { | ||||
/** | /** | ||||
* Vote history. | * Vote history. | ||||
Show All 37 Lines | public: | ||||
*/ | */ | ||||
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; | ||||
} | } | ||||
bool isInconclusive() const { | |||||
return successfulVotes > AVALANCHE_VOTE_INCONCLUSIVE_THRESHOLD; | |||||
} | |||||
/** | /** | ||||
* Register a new vote for an item and update confidence accordingly. | * Register a new vote for an item and update confidence accordingly. | ||||
* Returns true if the acceptance or finalization state changed. | * Returns true if the acceptance or finalization state changed. | ||||
*/ | */ | ||||
bool registerVote(NodeId nodeid, uint32_t error); | bool registerVote(NodeId nodeid, uint32_t error); | ||||
/** | /** | ||||
* Register that a request is being made regarding that item. | * Register that a request is being made regarding that item. | ||||
Show All 27 Lines |