Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche.cpp
// Copyright (c) 2018 The Bitcoin developers | // Copyright (c) 2018 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.h" | #include "avalanche.h" | ||||
#include "chain.h" | #include "chain.h" | ||||
#include "config/bitcoin-config.h" | #include "config/bitcoin-config.h" | ||||
#include "netmessagemaker.h" | #include "netmessagemaker.h" | ||||
#include "reverse_iterator.h" | |||||
#include "scheduler.h" | #include "scheduler.h" | ||||
#include "validation.h" | #include "validation.h" | ||||
#include <boost/range/adaptor/reversed.hpp> | |||||
#include <tuple> | #include <tuple> | ||||
static uint32_t countBits(uint32_t v) { | static uint32_t countBits(uint32_t v) { | ||||
#if HAVE_DECL___BUILTIN_POPCOUNT | #if HAVE_DECL___BUILTIN_POPCOUNT | ||||
return __builtin_popcount(v); | return __builtin_popcount(v); | ||||
#else | #else | ||||
/** | /** | ||||
* Computes the number of bits set in each group of 8bits then uses a | * Computes the number of bits set in each group of 8bits then uses a | ||||
▲ Show 20 Lines • Show All 287 Lines • ▼ Show 20 Lines | bool AvalancheProcessor::stopEventLoop() { | ||||
return true; | return true; | ||||
} | } | ||||
std::vector<CInv> AvalancheProcessor::getInvsForNextPoll() const { | std::vector<CInv> AvalancheProcessor::getInvsForNextPoll() 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 *, VoteRecord> &p : | for (const std::pair<const CBlockIndex *, VoteRecord> &p : | ||||
boost::adaptors::reverse(r)) { | reverse_iterate(r)) { | ||||
const CBlockIndex *pindex = p.first; | const CBlockIndex *pindex = p.first; | ||||
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; | ||||
} | } | ||||
// We don't have a decision, we need more votes. | // We don't have a decision, we need more votes. | ||||
invs.emplace_back(MSG_BLOCK, p.first->GetBlockHash()); | invs.emplace_back(MSG_BLOCK, p.first->GetBlockHash()); | ||||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |