Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche.cpp
Show First 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | bool isAccepted; | ||||
isAccepted = chainActive.Contains(pindex); | isAccepted = chainActive.Contains(pindex); | ||||
} | } | ||||
return vote_records.getWriteView() | return vote_records.getWriteView() | ||||
->insert(std::make_pair(pindex, VoteRecord(isAccepted))) | ->insert(std::make_pair(pindex, VoteRecord(isAccepted))) | ||||
.second; | .second; | ||||
} | } | ||||
static const VoteRecord * | bool AvalancheProcessor::isAccepted(const CBlockIndex *pindex) const { | ||||
GetRecord(const RWCollection<BlockVoteMap> &vote_records, | |||||
const CBlockIndex *pindex) { | |||||
auto r = vote_records.getReadView(); | auto r = vote_records.getReadView(); | ||||
auto it = r->find(pindex); | auto it = r->find(pindex); | ||||
if (it == r.end()) { | if (it == r.end()) { | ||||
return nullptr; | return false; | ||||
} | } | ||||
return &it->second; | return it->second.isAccepted(); | ||||
} | |||||
bool AvalancheProcessor::isAccepted(const CBlockIndex *pindex) const { | |||||
if (auto vr = GetRecord(vote_records, pindex)) { | |||||
return vr->isAccepted(); | |||||
} | |||||
return false; | |||||
} | } | ||||
int AvalancheProcessor::getConfidence(const CBlockIndex *pindex) const { | int AvalancheProcessor::getConfidence(const CBlockIndex *pindex) const { | ||||
if (auto vr = GetRecord(vote_records, pindex)) { | auto r = vote_records.getReadView(); | ||||
return vr->getConfidence(); | auto it = r->find(pindex); | ||||
if (it == r.end()) { | |||||
return -1; | |||||
} | } | ||||
return -1; | return it->second.getConfidence(); | ||||
} | } | ||||
bool AvalancheProcessor::registerVotes( | bool AvalancheProcessor::registerVotes( | ||||
NodeId nodeid, const AvalancheResponse &response, | NodeId nodeid, const AvalancheResponse &response, | ||||
std::vector<AvalancheBlockUpdate> &updates) { | std::vector<AvalancheBlockUpdate> &updates) { | ||||
{ | { | ||||
// Save the time at which we can query again. | // Save the time at which we can query again. | ||||
auto w = peerSet.getWriteView(); | auto w = peerSet.getWriteView(); | ||||
▲ Show 20 Lines • Show All 280 Lines • Show Last 20 Lines |