mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Merge pull request #6148
ae6f957
Enable block relay when pruning (Suhas Daftuar)0da6ae2
Do not inv old or missing blocks when pruning (Suhas Daftuar)
This commit is contained in:
commit
999c8be81a
12
src/main.cpp
12
src/main.cpp
@ -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,
|
||||
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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user