Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche.cpp
Show First 20 Lines • Show All 407 Lines • ▼ Show 20 Lines | |||||
std::vector<CInv> AvalancheProcessor::getInvsForNextPoll(bool forPoll) const { | std::vector<CInv> AvalancheProcessor::getInvsForNextPoll(bool forPoll) const { | ||||
std::vector<CInv> invs; | std::vector<CInv> invs; | ||||
auto r = vote_records.getReadView(); | auto r = vote_records.getReadView(); | ||||
for (const std::pair<const CBlockIndex *const, VoteRecord> &p : | for (const std::pair<const CBlockIndex *const, VoteRecord> &p : | ||||
reverse_iterate(r)) { | reverse_iterate(r)) { | ||||
const CBlockIndex *pindex = p.first; | const CBlockIndex *pindex = p.first; | ||||
{ | |||||
LOCK(cs_main); | |||||
if (!IsWorthPolling(pindex)) { | if (!IsWorthPolling(pindex)) { | ||||
// Obviously do not poll if the block is not worth polling. | // Obviously do not poll if the block is not worth polling. | ||||
continue; | continue; | ||||
} | } | ||||
} | |||||
// Check if we can run poll. | // Check if we can run poll. | ||||
const bool shouldPoll = | const bool shouldPoll = | ||||
forPoll ? p.second.registerPoll() : p.second.shouldPoll(); | forPoll ? p.second.registerPoll() : p.second.shouldPoll(); | ||||
if (!shouldPoll) { | if (!shouldPoll) { | ||||
continue; | continue; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | while (true) { | ||||
} | } | ||||
/** | /** | ||||
* If we lost contact to that node, then we remove it from nodeids, but | * If we lost contact to that node, then we remove it from nodeids, but | ||||
* never add the request to queries, which ensures bad nodes get cleaned | * never add the request to queries, which ensures bad nodes get cleaned | ||||
* up over time. | * up over time. | ||||
*/ | */ | ||||
std::vector<CInv> invs; | std::vector<CInv> invs; | ||||
LOCK(cs_main); | |||||
bool hasSent = connman->ForNode(nodeid, [this, &invs](CNode *pnode) { | bool hasSent = connman->ForNode(nodeid, [this, &invs](CNode *pnode) { | ||||
AssertLockHeld(cs_main); | |||||
invs = getInvsForNextPoll(); | invs = getInvsForNextPoll(); | ||||
if (invs.empty()) { | if (invs.empty()) { | ||||
return false; | return false; | ||||
} | } | ||||
uint64_t current_round = round++; | uint64_t current_round = round++; | ||||
{ | { | ||||
Show All 34 Lines |