Merge pull request #6012

0421c18 Fix CheckBlockIndex for reindex. (mrbandrews)
This commit is contained in:
Wladimir J. van der Laan
2015-04-16 10:27:25 +02:00
2 changed files with 42 additions and 0 deletions

View File

@@ -3232,6 +3232,14 @@ void static CheckBlockIndex()
LOCK(cs_main);
// During a reindex, we read the genesis block and call CheckBlockIndex before ActivateBestChain,
// so we have the genesis block in mapBlockIndex but no active chain. (A few of the tests when
// iterating the block tree require that chainActive has been initialized.)
if (chainActive.Height() < 0) {
assert(mapBlockIndex.size() <= 1);
return;
}
// Build forward-pointing map of the entire block tree.
std::multimap<CBlockIndex*,CBlockIndex*> forward;
for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); it++) {