diff options
author | Suhas Daftuar <sdaftuar@gmail.com> | 2015-06-02 15:17:36 -0400 |
---|---|---|
committer | Suhas Daftuar <sdaftuar@gmail.com> | 2015-06-03 11:36:04 -0400 |
commit | bfc30b34374d71928acee5ff41282f09cedfd5e4 (patch) | |
tree | 2647af91f5757f0981bd666f1cbc10d8032bcc5a /src/main.cpp | |
parent | 9d6060244429c4591e6ca62749f4f73cd981f247 (diff) |
Ignore unrequested blocks too far ahead of tip
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index 760cda5dee..e0997515b7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2841,9 +2841,15 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex, // Try to process all requested blocks that we don't have, but only // process an unrequested block if it's new and has enough work to - // advance our tip. + // advance our tip, and isn't too many blocks ahead. bool fAlreadyHave = pindex->nStatus & BLOCK_HAVE_DATA; bool fHasMoreWork = (chainActive.Tip() ? pindex->nChainWork > chainActive.Tip()->nChainWork : true); + // Blocks that are too out-of-order needlessly limit the effectiveness of + // pruning, because pruning will not delete block files that contain any + // blocks which are too close in height to the tip. Apply this test + // regardless of whether pruning is enabled; it should generally be safe to + // not process unrequested blocks. + bool fTooFarAhead = (pindex->nHeight - chainActive.Height()) > MIN_BLOCKS_TO_KEEP; // TODO: deal better with return value and error conditions for duplicate // and unrequested blocks. @@ -2851,6 +2857,7 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex, if (!fRequested) { // If we didn't ask for it: if (pindex->nTx != 0) return true; // This is a previously-processed block that was pruned if (!fHasMoreWork) return true; // Don't process less-work chains + if (fTooFarAhead) return true; // Block height is too high } if ((!CheckBlock(block, state)) || !ContextualCheckBlock(block, state, pindex->pprev)) { |