Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 3,789 Lines • ▼ Show 20 Lines | if (isSameHeight) { | ||||
"diff=%d\n", | "diff=%d\n", | ||||
chainActive.Tip()->GetBlockHash().ToString(), | chainActive.Tip()->GetBlockHash().ToString(), | ||||
chainTipTimeDiff); | chainTipTimeDiff); | ||||
LogPrintf("New block timestamp-to-received-time difference: hash=%s, " | LogPrintf("New block timestamp-to-received-time difference: hash=%s, " | ||||
"diff=%d\n", | "diff=%d\n", | ||||
pindex->GetBlockHash().ToString(), newBlockTimeDiff); | pindex->GetBlockHash().ToString(), newBlockTimeDiff); | ||||
} | } | ||||
bool fHasMoreWork = | bool fHasMoreOrSameWork = | ||||
(chainActive.Tip() ? pindex->nChainWork > chainActive.Tip()->nChainWork | (chainActive.Tip() ? pindex->nChainWork >= chainActive.Tip()->nChainWork | ||||
: true); | : true); | ||||
// Blocks that are too out-of-order needlessly limit the effectiveness of | // Blocks that are too out-of-order needlessly limit the effectiveness of | ||||
// pruning, because pruning will not delete block files that contain any | // pruning, because pruning will not delete block files that contain any | ||||
// blocks which are too close in height to the tip. Apply this test | // 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 | // regardless of whether pruning is enabled; it should generally be safe to | ||||
// not process unrequested blocks. | // not process unrequested blocks. | ||||
bool fTooFarAhead = | bool fTooFarAhead = | ||||
(pindex->nHeight > int(chainActive.Height() + MIN_BLOCKS_TO_KEEP)); | (pindex->nHeight > int(chainActive.Height() + MIN_BLOCKS_TO_KEEP)); | ||||
// TODO: Decouple this function from the block download logic by removing | // TODO: Decouple this function from the block download logic by removing | ||||
// fRequested | // fRequested | ||||
// This requires some new chain datastructure to efficiently look up if a | // This requires some new chain datastructure to efficiently look up if a | ||||
// block is in a chain leading to a candidate for best tip, despite not | // block is in a chain leading to a candidate for best tip, despite not | ||||
// being such a candidate itself. | // being such a candidate itself. | ||||
// If we didn't ask for it: | // If we didn't ask for it: | ||||
if (!fRequested) { | if (!fRequested) { | ||||
// This is a previously-processed block that was pruned. | // This is a previously-processed block that was pruned. | ||||
if (pindex->nTx != 0) { | if (pindex->nTx != 0) { | ||||
return true; | return true; | ||||
} | } | ||||
// Don't process less-work chains. | // Don't process less-work chains. | ||||
if (!fHasMoreWork) { | if (!fHasMoreOrSameWork) { | ||||
return true; | return true; | ||||
} | } | ||||
// Block height is too high. | // Block height is too high. | ||||
if (fTooFarAhead) { | if (fTooFarAhead) { | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,678 Lines • Show Last 20 Lines |