aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-04-03 15:30:04 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-04-04 07:38:02 +0200
commitfa9b74f5ea89624e052934c48391b5076a87ffef (patch)
tree75a78b8535b82129fd3105b6c3c50f06ea3db14b /src/validation.cpp
parentfa8fffebe8ac126f31143619843dd6578a2f4e3c (diff)
downloadbitcoin-fa9b74f5ea89624e052934c48391b5076a87ffef.tar.xz
Fix assumeutxo crash due to missing base_blockhash
Diffstat (limited to 'src/validation.cpp')
-rw-r--r--src/validation.cpp34
1 files changed, 9 insertions, 25 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index 19363c0efb..619d3cea98 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -5423,6 +5423,15 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
assert(coins_cache.GetBestBlock() == base_blockhash);
+ CBlockIndex* snapshot_start_block = WITH_LOCK(::cs_main, return m_blockman.LookupBlockIndex(base_blockhash));
+
+ if (!snapshot_start_block) {
+ // Needed for GetUTXOStats to determine the height
+ LogPrintf("[snapshot] Did not find snapshot start blockheader %s\n",
+ base_blockhash.ToString());
+ return false;
+ }
+
CCoinsStats stats;
auto breakpoint_fnc = [] { /* TODO insert breakpoint here? */ };
@@ -5435,31 +5444,6 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
return false;
}
- // Ensure that the base blockhash appears in the known chain of valid headers. We're willing to
- // wait a bit here because the snapshot may have been loaded on startup, before we've
- // received headers from the network.
-
- int max_secs_to_wait_for_headers = 60 * 10;
- CBlockIndex* snapshot_start_block = nullptr;
-
- while (max_secs_to_wait_for_headers > 0) {
- snapshot_start_block = WITH_LOCK(::cs_main,
- return m_blockman.LookupBlockIndex(base_blockhash));
- --max_secs_to_wait_for_headers;
-
- if (!snapshot_start_block) {
- std::this_thread::sleep_for(std::chrono::seconds(1));
- } else {
- break;
- }
- }
-
- if (snapshot_start_block == nullptr) {
- LogPrintf("[snapshot] timed out waiting for snapshot start blockheader %s\n",
- base_blockhash.ToString());
- return false;
- }
-
// Assert that the deserialized chainstate contents match the expected assumeutxo value.
int base_height = snapshot_start_block->nHeight;