Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/voterecord.cpp
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | bool VoteRecord::registerVote(NodeId nodeid, uint32_t error) { | ||||
} | } | ||||
// The round changed our state. We reset the confidence. | // The round changed our state. We reset the confidence. | ||||
confidence = yes; | confidence = yes; | ||||
return true; | return true; | ||||
} | } | ||||
bool VoteRecord::addNodeToQuorum(NodeId nodeid) { | bool VoteRecord::addNodeToQuorum(NodeId nodeid) { | ||||
if (nodeid == NO_NODE) { | |||||
// Helpful for testing. | |||||
return true; | |||||
} | |||||
// MMIX Linear Congruent Generator. | // MMIX Linear Congruent Generator. | ||||
const uint64_t r1 = | const uint64_t r1 = | ||||
6364136223846793005 * uint64_t(nodeid) + 1442695040888963407; | 6364136223846793005 * uint64_t(nodeid) + 1442695040888963407; | ||||
// Fibonacci hashing. | // Fibonacci hashing. | ||||
const uint64_t r2 = 11400714819323198485ull * (nodeid ^ seed); | const uint64_t r2 = 11400714819323198485ull * (nodeid ^ seed); | ||||
// Combine and extract hash. | // Combine and extract hash. | ||||
const uint16_t h = (r1 + r2) >> 48; | const uint16_t h = (r1 + r2) >> 48; | ||||
Show All 29 Lines |