Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 2,568 Lines • ▼ Show 20 Lines | do { | ||||
CBlockIndex *pindexTest = pindexNew; | CBlockIndex *pindexTest = pindexNew; | ||||
bool hasValidAncestor = true; | bool hasValidAncestor = true; | ||||
while (hasValidAncestor && pindexTest && pindexTest != pindexFork) { | while (hasValidAncestor && pindexTest && pindexTest != pindexFork) { | ||||
assert(pindexTest->HaveTxsDownloaded() || pindexTest->nHeight == 0); | assert(pindexTest->HaveTxsDownloaded() || pindexTest->nHeight == 0); | ||||
// If this is a parked chain, but it has enough PoW, clear the park | // If this is a parked chain, but it has enough PoW, clear the park | ||||
// state. | // state. | ||||
bool fParkedChain = pindexTest->nStatus.isOnParkedChain(); | bool fParkedChain = pindexTest->nStatus.isOnParkedChain(); | ||||
if (fParkedChain && gArgs.GetBoolArg("-parkdeepreorg", true)) { | if (fParkedChain && gArgs.GetBoolArg("-automaticunparking", true)) { | ||||
const CBlockIndex *pindexTip = chainActive.Tip(); | const CBlockIndex *pindexTip = chainActive.Tip(); | ||||
// During initialization, pindexTip and/or pindexFork may be | // During initialization, pindexTip and/or pindexFork may be | ||||
// null. In this case, we just ignore the fact that the chain is | // null. In this case, we just ignore the fact that the chain is | ||||
// parked. | // parked. | ||||
if (!pindexTip || !pindexFork) { | if (!pindexTip || !pindexFork) { | ||||
UnparkBlock(pindexTest); | UnparkBlock(pindexTest); | ||||
continue; | continue; | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | do { | ||||
} | } | ||||
if (fParkedChain && | if (fParkedChain && | ||||
(pindexBestParked == nullptr || | (pindexBestParked == nullptr || | ||||
pindexNew->nChainWork > pindexBestParked->nChainWork)) { | pindexNew->nChainWork > pindexBestParked->nChainWork)) { | ||||
pindexBestParked = pindexNew; | pindexBestParked = pindexNew; | ||||
} | } | ||||
LogPrintf("Considered switcing to better tip %s but that chain " | |||||
"contains a%s%s%s block.\n", | |||||
pindexNew->GetBlockHash().ToString(), | |||||
fInvalidChain ? "n invalid" : "", | |||||
fParkedChain ? " parked" : "", | |||||
fMissingData ? " missing-data" : ""); | |||||
markblundeberg: Not strictly in-scope, but I found this to be a very helpful log message when figuring out what… | |||||
CBlockIndex *pindexFailed = pindexNew; | CBlockIndex *pindexFailed = pindexNew; | ||||
// Remove the entire chain from the set. | // Remove the entire chain from the set. | ||||
while (pindexTest != pindexFailed) { | while (pindexTest != pindexFailed) { | ||||
if (fInvalidChain || fParkedChain) { | if (fInvalidChain || fParkedChain) { | ||||
pindexFailed->nStatus = | pindexFailed->nStatus = | ||||
pindexFailed->nStatus.withFailedParent(fInvalidChain) | pindexFailed->nStatus.withFailedParent(fInvalidChain) | ||||
.withParkedParent(fParkedChain); | .withParkedParent(fParkedChain); | ||||
} else if (fMissingData) { | } else if (fMissingData) { | ||||
▲ Show 20 Lines • Show All 3,047 Lines • Show Last 20 Lines |
Not strictly in-scope, but I found this to be a very helpful log message when figuring out what is happening. Happy to move it to another diff if that is wanted.