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 before a record is flagged as stale. | |||||
*/ | |||||
static constexpr int AVALANCHE_VOTE_STALE_THRESHOLD = 1024; | |||||
Fabien: This should be unsigned | |||||
/** | |||||
* 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 isStale() const { | |||||
return successfulVotes > AVALANCHE_VOTE_STALE_THRESHOLD; | |||||
FabienUnsubmitted Not Done Inline ActionsWould that makes sense to check confidence < 1 as well ? Fabien: Would that makes sense to check confidence < 1 as well ? | |||||
sdulfariAuthorUnsubmitted Done Inline ActionsI considered that and decided against it since it doesn't add any real benefit. In the rare case this happens at random, being marked as stale is not the end of the world for this vote record. In the adversarial case, an attacker need only tweak the attack design. sdulfari: I considered that and decided against it since it doesn't add any real benefit. In the rare… | |||||
} | |||||
/** | /** | ||||
* 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 |
This should be unsigned