aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-04-16 10:27:25 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2015-04-16 10:33:29 +0200
commit8f955b9661224adc950e302b42d2f7bcb5e90bef (patch)
tree0a153de67ade81f4b50518191314660a75e6a95b /src
parentbc8535b7175ea4b1bff49fe6bef32017cf5f472a (diff)
parent0421c18f3a261f04e83a03f59884e5798af74fd9 (diff)
downloadbitcoin-8f955b9661224adc950e302b42d2f7bcb5e90bef.tar.xz
Merge pull request #6012
0421c18 Fix CheckBlockIndex for reindex. (mrbandrews)
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index f0aa3022cd..8dd61a3720 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -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++) {