Changeset View
Changeset View
Standalone View
Standalone View
src/net.cpp
Show First 20 Lines • Show All 3,138 Lines • ▼ Show 20 Lines | void CNode::AvalancheState::updateAvailabilityScore() { | ||||
uint64_t windowInvCounters = invCounters.exchange(0); | uint64_t windowInvCounters = invCounters.exchange(0); | ||||
double previousScore = availabilityScore; | double previousScore = availabilityScore; | ||||
uint32_t polls = windowInvCounters & std::numeric_limits<uint32_t>::max(); | uint32_t polls = windowInvCounters & std::numeric_limits<uint32_t>::max(); | ||||
uint32_t votes = windowInvCounters >> 32; | uint32_t votes = windowInvCounters >> 32; | ||||
availabilityScore = | availabilityScore = | ||||
AVALANCHE_STATISTICS_DECAY_FACTOR * (2 * votes - polls) + | AVALANCHE_STATISTICS_DECAY_FACTOR * (int64_t(2 * votes - polls) - 1) + | ||||
(1. - AVALANCHE_STATISTICS_DECAY_FACTOR) * previousScore; | (1. - AVALANCHE_STATISTICS_DECAY_FACTOR) * previousScore; | ||||
} | } | ||||
double CNode::AvalancheState::getAvailabilityScore() const { | double CNode::AvalancheState::getAvailabilityScore() const { | ||||
// The score is set atomically so there is no need to lock the statistics | // The score is set atomically so there is no need to lock the statistics | ||||
// when reading. | // when reading. | ||||
return availabilityScore; | return availabilityScore; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 184 Lines • Show Last 20 Lines |