Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 386 Lines • ▼ Show 20 Lines | |||||
MarkBlockAsInFlight(const Config &config, NodeId nodeid, const uint256 &hash, | MarkBlockAsInFlight(const Config &config, NodeId nodeid, const uint256 &hash, | ||||
const Consensus::Params &consensusParams, | const Consensus::Params &consensusParams, | ||||
const CBlockIndex *pindex = nullptr, | const CBlockIndex *pindex = nullptr, | ||||
std::list<QueuedBlock>::iterator **pit = nullptr) | std::list<QueuedBlock>::iterator **pit = nullptr) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | ||||
CNodeState *state = State(nodeid); | CNodeState *state = State(nodeid); | ||||
assert(state != nullptr); | assert(state != nullptr); | ||||
// Short-circuit most stuff in case its from the same node. | // Short-circuit most stuff in case it is from the same node. | ||||
std::map<uint256, | std::map<uint256, | ||||
std::pair<NodeId, std::list<QueuedBlock>::iterator>>::iterator | std::pair<NodeId, std::list<QueuedBlock>::iterator>>::iterator | ||||
itInFlight = mapBlocksInFlight.find(hash); | itInFlight = mapBlocksInFlight.find(hash); | ||||
if (itInFlight != mapBlocksInFlight.end() && | if (itInFlight != mapBlocksInFlight.end() && | ||||
itInFlight->second.first == nodeid) { | itInFlight->second.first == nodeid) { | ||||
if (pit) { | if (pit) { | ||||
*pit = &itInFlight->second.second; | *pit = &itInFlight->second.second; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 221 Lines • ▼ Show 20 Lines | while (pindexWalk->nHeight < nMaxHeight) { | ||||
pindexWalk->nHeight + nToFetch); | pindexWalk->nHeight + nToFetch); | ||||
vToFetch[nToFetch - 1] = pindexWalk; | vToFetch[nToFetch - 1] = pindexWalk; | ||||
for (unsigned int i = nToFetch - 1; i > 0; i--) { | for (unsigned int i = nToFetch - 1; i > 0; i--) { | ||||
vToFetch[i - 1] = vToFetch[i]->pprev; | vToFetch[i - 1] = vToFetch[i]->pprev; | ||||
} | } | ||||
// Iterate over those blocks in vToFetch (in forward direction), adding | // Iterate over those blocks in vToFetch (in forward direction), adding | ||||
// the ones that are not yet downloaded and not in flight to vBlocks. In | // the ones that are not yet downloaded and not in flight to vBlocks. In | ||||
// the mean time, update pindexLastCommonBlock as long as all ancestors | // the meantime, update pindexLastCommonBlock as long as all ancestors | ||||
// are already downloaded, or if it's already part of our chain (and | // are already downloaded, or if it's already part of our chain (and | ||||
// therefore don't need it even if pruned). | // therefore don't need it even if pruned). | ||||
for (const CBlockIndex *pindex : vToFetch) { | for (const CBlockIndex *pindex : vToFetch) { | ||||
if (!pindex->IsValid(BlockValidity::TREE)) { | if (!pindex->IsValid(BlockValidity::TREE)) { | ||||
// We consider the chain that this peer is on invalid. | // We consider the chain that this peer is on invalid. | ||||
return; | return; | ||||
} | } | ||||
if (pindex->nStatus.hasData() || chainActive.Contains(pindex)) { | if (pindex->nStatus.hasData() || chainActive.Contains(pindex)) { | ||||
▲ Show 20 Lines • Show All 3,730 Lines • Show Last 20 Lines |