From 290612e9db452b92be3f93bc9cef0caeb4f7d766 Mon Sep 17 00:00:00 2001 From: Just Wonder Date: Sat, 9 May 2020 10:26:13 -0700 Subject: [PATCH] Fixed lock during block downloading. --- src/primitives/block.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp index f6494be1e..260d5fe3b 100644 --- a/src/primitives/block.cpp +++ b/src/primitives/block.cpp @@ -21,8 +21,9 @@ static void cn_get_block_hash_by_height(uint64_t seed_height, char cnHash[32]) { CBlockIndex* pblockindex = chainActive[seed_height]; if (pblockindex == NULL) { - AssertLockHeld(cs_main); - // This will only happens during initial block download. + // This will happen during initial block downloading, or when we + // are out of sync by more than at least SEEDHASH_EPOCH_BLOCKS blocks. + LOCK(cs_main); pblockindex = mapBlockSeedHeight.find(seed_height)->second; } if (pblockindex == NULL) {