Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 766 Lines • ▼ Show 20 Lines | while (pindexWalk->nHeight < nMaxHeight) { | ||||
// 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)) { | ||||
if (pindex->nChainTx) { | if (pindex->HaveTxsDownloaded()) { | ||||
state->pindexLastCommonBlock = pindex; | state->pindexLastCommonBlock = pindex; | ||||
} | } | ||||
} else if (mapBlocksInFlight.count(pindex->GetBlockHash()) == 0) { | } else if (mapBlocksInFlight.count(pindex->GetBlockHash()) == 0) { | ||||
// The block is not already downloaded, and not yet in flight. | // The block is not already downloaded, and not yet in flight. | ||||
if (pindex->nHeight > nWindowEnd) { | if (pindex->nHeight > nWindowEnd) { | ||||
// We reached the end of the window. | // We reached the end of the window. | ||||
if (vBlocks.size() == 0 && waitingfor != nodeid) { | if (vBlocks.size() == 0 && waitingfor != nodeid) { | ||||
// We aren't able to fetch anything, but we would be if | // We aren't able to fetch anything, but we would be if | ||||
▲ Show 20 Lines • Show All 701 Lines • ▼ Show 20 Lines | std::shared_ptr<const CBlockHeaderAndShortTxIDs> a_recent_compact_block; | ||||
a_recent_compact_block = most_recent_compact_block; | a_recent_compact_block = most_recent_compact_block; | ||||
} | } | ||||
bool need_activate_chain = false; | bool need_activate_chain = false; | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
const CBlockIndex *pindex = LookupBlockIndex(hash); | const CBlockIndex *pindex = LookupBlockIndex(hash); | ||||
if (pindex) { | if (pindex) { | ||||
if (pindex->nChainTx && !pindex->IsValid(BlockValidity::SCRIPTS) && | if (pindex->HaveTxsDownloaded() && | ||||
!pindex->IsValid(BlockValidity::SCRIPTS) && | |||||
pindex->IsValid(BlockValidity::TREE)) { | pindex->IsValid(BlockValidity::TREE)) { | ||||
// If we have the block and all of its parents, but have not yet | // If we have the block and all of its parents, but have not yet | ||||
// validated it, we might be in the middle of connecting it (ie | // validated it, we might be in the middle of connecting it (ie | ||||
// in the unlock of cs_main before ActivateBestChain but after | // in the unlock of cs_main before ActivateBestChain but after | ||||
// AcceptBlock). In this case, we need to run ActivateBestChain | // AcceptBlock). In this case, we need to run ActivateBestChain | ||||
// prior to checking the relay conditions below. | // prior to checking the relay conditions below. | ||||
need_activate_chain = true; | need_activate_chain = true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 3,227 Lines • Show Last 20 Lines |