@@ -5423,6 +5423,15 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
5423
5423
5424
5424
assert (coins_cache.GetBestBlock () == base_blockhash);
5425
5425
5426
+ CBlockIndex* snapshot_start_block = WITH_LOCK (::cs_main, return m_blockman.LookupBlockIndex (base_blockhash));
5427
+
5428
+ if (!snapshot_start_block) {
5429
+ // Needed for GetUTXOStats to determine the height
5430
+ LogPrintf (" [snapshot] Did not find snapshot start blockheader %s\n " ,
5431
+ base_blockhash.ToString ());
5432
+ return false ;
5433
+ }
5434
+
5426
5435
CCoinsStats stats;
5427
5436
auto breakpoint_fnc = [] { /* TODO insert breakpoint here? */ };
5428
5437
@@ -5435,31 +5444,6 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
5435
5444
return false ;
5436
5445
}
5437
5446
5438
- // Ensure that the base blockhash appears in the known chain of valid headers. We're willing to
5439
- // wait a bit here because the snapshot may have been loaded on startup, before we've
5440
- // received headers from the network.
5441
-
5442
- int max_secs_to_wait_for_headers = 60 * 10 ;
5443
- CBlockIndex* snapshot_start_block = nullptr ;
5444
-
5445
- while (max_secs_to_wait_for_headers > 0 ) {
5446
- snapshot_start_block = WITH_LOCK (::cs_main,
5447
- return m_blockman.LookupBlockIndex (base_blockhash));
5448
- --max_secs_to_wait_for_headers;
5449
-
5450
- if (!snapshot_start_block) {
5451
- std::this_thread::sleep_for (std::chrono::seconds (1 ));
5452
- } else {
5453
- break ;
5454
- }
5455
- }
5456
-
5457
- if (snapshot_start_block == nullptr ) {
5458
- LogPrintf (" [snapshot] timed out waiting for snapshot start blockheader %s\n " ,
5459
- base_blockhash.ToString ());
5460
- return false ;
5461
- }
5462
-
5463
5447
// Assert that the deserialized chainstate contents match the expected assumeutxo value.
5464
5448
5465
5449
int base_height = snapshot_start_block->nHeight ;
0 commit comments