Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.cpp
// Copyright (c) 2018-2019 The Bitcoin developers | // Copyright (c) 2018-2019 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <avalanche/processor.h> | #include <avalanche/processor.h> | ||||
#include <avalanche/avalanche.h> | |||||
#include <avalanche/delegationbuilder.h> | #include <avalanche/delegationbuilder.h> | ||||
#include <avalanche/peermanager.h> | #include <avalanche/peermanager.h> | ||||
#include <avalanche/validation.h> | #include <avalanche/validation.h> | ||||
#include <avalanche/voterecord.h> | #include <avalanche/voterecord.h> | ||||
#include <chain.h> | #include <chain.h> | ||||
#include <key_io.h> // For DecodeSecret | #include <key_io.h> // For DecodeSecret | ||||
#include <net.h> | #include <net.h> | ||||
#include <netmessagemaker.h> | #include <netmessagemaker.h> | ||||
▲ Show 20 Lines • Show All 460 Lines • ▼ Show 20 Lines | |||||
bool Processor::stopEventLoop() { | bool Processor::stopEventLoop() { | ||||
return eventLoop.stopEventLoop(); | return eventLoop.stopEventLoop(); | ||||
} | } | ||||
std::vector<CInv> Processor::getInvsForNextPoll(bool forPoll) { | std::vector<CInv> Processor::getInvsForNextPoll(bool forPoll) { | ||||
std::vector<CInv> invs; | std::vector<CInv> invs; | ||||
if (gArgs.GetBoolArg("-enableavalancheproofvoting", | |||||
AVALANCHE_DEFAULT_PROOF_VOTING_ENABLED)) { | |||||
auto getConflictingProofs = [this]() { | |||||
LOCK(cs_peerManager); | |||||
return peerManager->getConflictingProofs(); | |||||
}; | |||||
auto conflictingProofsReadView = getConflictingProofs(); | |||||
auto it = conflictingProofsReadView.begin(); | |||||
// Clamp to AVALANCHE_MAX_ELEMENT_POLL - 1 so we're always able to poll | |||||
// for a new block. | |||||
while (it != conflictingProofsReadView.end() && | |||||
invs.size() < AVALANCHE_MAX_ELEMENT_POLL - 1) { | |||||
invs.emplace_back(MSG_AVA_PROOF, it->first->getId()); | |||||
++it; | |||||
} | |||||
deadalnix: This whole mess this to be a pretty string signal to me that this list belong in the Processor… | |||||
} | |||||
// 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 = vote_records.getWriteView(); | auto w = vote_records.getWriteView(); | ||||
for (auto it = w->begin(); it != w->end();) { | for (auto it = w->begin(); it != w->end();) { | ||||
const CBlockIndex *pindex = it->first; | const CBlockIndex *pindex = it->first; | ||||
if (!IsWorthPolling(pindex)) { | if (!IsWorthPolling(pindex)) { | ||||
w->erase(it++); | w->erase(it++); | ||||
▲ Show 20 Lines • Show All 148 Lines • Show Last 20 Lines |
This whole mess this to be a pretty string signal to me that this list belong in the Processor, just like blocks, not in the PeerManager.