Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.cpp
Show First 20 Lines • Show All 536 Lines • ▼ Show 20 Lines | std::vector<CInv> Processor::getInvsForNextPoll(bool forPoll) { | ||||
auto proofVoteRecordsReadView = proofVoteRecords.getReadView(); | auto proofVoteRecordsReadView = proofVoteRecords.getReadView(); | ||||
auto pit = proofVoteRecordsReadView.begin(); | auto pit = proofVoteRecordsReadView.begin(); | ||||
// Clamp to AVALANCHE_MAX_ELEMENT_POLL - 1 so we're always able to poll | // Clamp to AVALANCHE_MAX_ELEMENT_POLL - 1 so we're always able to poll | ||||
// for a new block. Since the proofs are sorted by score, the most | // for a new block. Since the proofs are sorted by score, the most | ||||
// valuable are voted first. | // valuable are voted first. | ||||
while (pit != proofVoteRecordsReadView.end() && | while (pit != proofVoteRecordsReadView.end() && | ||||
invs.size() < AVALANCHE_MAX_ELEMENT_POLL - 1) { | invs.size() < AVALANCHE_MAX_ELEMENT_POLL - 1) { | ||||
const bool shouldPoll = | |||||
forPoll ? pit->second.registerPoll() : pit->second.shouldPoll(); | |||||
if (shouldPoll) { | |||||
invs.emplace_back(MSG_AVA_PROOF, pit->first->getId()); | invs.emplace_back(MSG_AVA_PROOF, pit->first->getId()); | ||||
} | |||||
++pit; | ++pit; | ||||
} | } | ||||
// First remove all blocks that are not worth polling. | // First remove all blocks that are not worth polling. | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
auto w = blockVoteRecords.getWriteView(); | auto w = blockVoteRecords.getWriteView(); | ||||
for (auto it = w->begin(); it != w->end();) { | for (auto it = w->begin(); it != w->end();) { | ||||
▲ Show 20 Lines • Show All 160 Lines • Show Last 20 Lines |