|
|
|
@ -2315,9 +2315,7 @@ bool ActivateBestChain(CValidationState &state, const CBlock *pblock) {
@@ -2315,9 +2315,7 @@ bool ActivateBestChain(CValidationState &state, const CBlock *pblock) {
|
|
|
|
|
int nBlockEstimate = 0; |
|
|
|
|
if (fCheckpointsEnabled) |
|
|
|
|
nBlockEstimate = Checkpoints::GetTotalBlocksEstimate(chainParams.Checkpoints()); |
|
|
|
|
// Don't relay blocks if pruning -- could cause a peer to try to download, resulting
|
|
|
|
|
// in a stalled download if the block file is pruned before the request.
|
|
|
|
|
if (nLocalServices & NODE_NETWORK) { |
|
|
|
|
{ |
|
|
|
|
LOCK(cs_vNodes); |
|
|
|
|
BOOST_FOREACH(CNode* pnode, vNodes) |
|
|
|
|
if (chainActive.Height() > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : nBlockEstimate)) |
|
|
|
@ -4198,6 +4196,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
@@ -4198,6 +4196,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|
|
|
|
LogPrint("net", " getblocks stopping at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
// If pruning, don't inv blocks unless we have on disk and are likely to still have
|
|
|
|
|
// for some reasonable time window (1 hour) that block relay might require.
|
|
|
|
|
const int nPrunedBlocksLikelyToHave = MIN_BLOCKS_TO_KEEP - 3600 / chainparams.GetConsensus().nPowTargetSpacing; |
|
|
|
|
if (fPruneMode && (!(pindex->nStatus & BLOCK_HAVE_DATA) || pindex->nHeight <= chainActive.Tip()->nHeight - nPrunedBlocksLikelyToHave)) |
|
|
|
|
{ |
|
|
|
|
LogPrint("net", " getblocks stopping, pruned or too old block at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash())); |
|
|
|
|
if (--nLimit <= 0) |
|
|
|
|
{ |
|
|
|
|