Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 4,809 Lines • ▼ Show 20 Lines | while (pindex != nullptr) { | ||||
assert(pindex->nSequenceId <= 0); | assert(pindex->nSequenceId <= 0); | ||||
} | } | ||||
// VALID_TRANSACTIONS is equivalent to nTx > 0 for all nodes (whether or | // VALID_TRANSACTIONS is equivalent to nTx > 0 for all nodes (whether or | ||||
// not pruning has occurred). HAVE_DATA is only equivalent to nTx > 0 | // not pruning has occurred). HAVE_DATA is only equivalent to nTx > 0 | ||||
// (or VALID_TRANSACTIONS) if no pruning has occurred. | // (or VALID_TRANSACTIONS) if no pruning has occurred. | ||||
if (!fHavePruned) { | if (!fHavePruned) { | ||||
// If we've never pruned, then HAVE_DATA should be equivalent to nTx | // If we've never pruned, then HAVE_DATA should be equivalent to nTx | ||||
// > 0 | // > 0 | ||||
assert(!pindex->nStatus.hasData() == (pindex->nTx == 0)); | assert(pindex->nStatus.hasData() == (pindex->nTx > 0)); | ||||
assert(pindexFirstMissing == pindexFirstNeverProcessed); | assert(pindexFirstMissing == pindexFirstNeverProcessed); | ||||
} else if (pindex->nStatus.hasData()) { | } else if (pindex->nStatus.hasData()) { | ||||
// If we have pruned, then we can only say that HAVE_DATA implies | // If we have pruned, then we can only say that HAVE_DATA implies | ||||
// nTx > 0 | // nTx > 0 | ||||
assert(pindex->nTx > 0); | assert(pindex->nTx > 0); | ||||
} | } | ||||
if (pindex->nStatus.hasUndo()) { | if (pindex->nStatus.hasUndo()) { | ||||
assert(pindex->nStatus.hasData()); | assert(pindex->nStatus.hasData()); | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | while (pindex != nullptr) { | ||||
// The failed mask cannot be set for blocks without invalid parents. | // The failed mask cannot be set for blocks without invalid parents. | ||||
assert(!pindex->nStatus.isOnParkedChain()); | assert(!pindex->nStatus.isOnParkedChain()); | ||||
} | } | ||||
if (!CBlockIndexWorkComparator()(pindex, chainActive.Tip()) && | if (!CBlockIndexWorkComparator()(pindex, chainActive.Tip()) && | ||||
pindexFirstNeverProcessed == nullptr) { | pindexFirstNeverProcessed == nullptr) { | ||||
if (pindexFirstInvalid == nullptr) { | if (pindexFirstInvalid == nullptr) { | ||||
// If this block sorts at least as good as the current tip and | // If this block sorts at least as good as the current tip and | ||||
// is valid and we have all data for its parents, it must be in | // is valid and we have all data for its parents, it must be in | ||||
// setBlockIndexCandidates. chainActive.Tip() must also be there | // setBlockIndexCandidates or be parked. | ||||
// even if some data has been pruned. | if (pindexFirstMissing == nullptr) { | ||||
if (pindexFirstMissing == nullptr || | assert(pindex->nStatus.isOnParkedChain() || | ||||
pindex == chainActive.Tip()) { | setBlockIndexCandidates.count(pindex)); | ||||
} | |||||
// chainActive.Tip() must also be there even if some data has | |||||
// been pruned. | |||||
if (pindex == chainActive.Tip()) { | |||||
assert(setBlockIndexCandidates.count(pindex)); | assert(setBlockIndexCandidates.count(pindex)); | ||||
} | } | ||||
// If some parent is missing, then it could be that this block | // If some parent is missing, then it could be that this block | ||||
// was in setBlockIndexCandidates but had to be removed because | // was in setBlockIndexCandidates but had to be removed because | ||||
// of the missing data. In this case it must be in | // of the missing data. In this case it must be in | ||||
// mapBlocksUnlinked -- see test below. | // mapBlocksUnlinked -- see test below. | ||||
} | } | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 305 Lines • Show Last 20 Lines |