Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.cpp
Show First 20 Lines • Show All 530 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
std::vector<CInv> Processor::getInvsForNextPoll(bool forPoll) { | std::vector<CInv> Processor::getInvsForNextPoll(bool forPoll) { | ||||
std::vector<CInv> invs; | std::vector<CInv> invs; | ||||
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 | // TODO Factorize the proof and block loops | ||||
// for a new block. Since the proofs are sorted by score, the most | |||||
// 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) { | ||||
const bool shouldPoll = | const bool shouldPoll = | ||||
forPoll ? pit->second.registerPoll() : pit->second.shouldPoll(); | forPoll ? pit->second.registerPoll() : pit->second.shouldPoll(); | ||||
if (shouldPoll) { | if (shouldPoll) { | ||||
invs.emplace_back(MSG_AVA_PROOF, pit->first->getId()); | invs.emplace_back(MSG_AVA_PROOF, pit->first->getId()); | ||||
} | } | ||||
++pit; | ++pit; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 165 Lines • Show Last 20 Lines |