diff --git a/src/avalanche.h b/src/avalanche.h --- a/src/avalanche.h +++ b/src/avalanche.h @@ -55,6 +55,10 @@ */ struct VoteRecord { private: + // confidence's LSB bit is the result. Higher bits are actual confidence + // score. + uint16_t confidence = 0; + // Historical record of votes. uint8_t votes = 0; // Each bit indicate if the vote is to be considered. @@ -62,9 +66,8 @@ // How many in flight requests exists for this element. mutable std::atomic inflight{0}; - // confidence's LSB bit is the result. Higher bits are actual confidence - // score. - uint16_t confidence = 0; + // Track how many successful votes occured. + uint32_t successfulVotes = 0; public: VoteRecord(bool accepted) : confidence(accepted) {} @@ -73,8 +76,9 @@ * Copy semantic */ VoteRecord(const VoteRecord &other) - : votes(other.votes), consider(other.consider), - inflight(other.inflight.load()), confidence(other.confidence) {} + : confidence(other.confidence), votes(other.votes), + consider(other.consider), inflight(other.inflight.load()), + successfulVotes(other.successfulVotes) {} /** * Vote accounting facilities. diff --git a/src/avalanche.cpp b/src/avalanche.cpp --- a/src/avalanche.cpp +++ b/src/avalanche.cpp @@ -44,6 +44,9 @@ // We just got a new vote, so there is one less inflight request. clearInflightRequest(); + // Keep track of how many votes were registered. + successfulVotes++; + /** * 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