@@ -5423,6 +5423,15 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
54235423
54245424 assert (coins_cache.GetBestBlock () == base_blockhash);
54255425
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+
54265435 CCoinsStats stats;
54275436 auto breakpoint_fnc = [] { /* TODO insert breakpoint here? */ };
54285437
@@ -5435,31 +5444,6 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
54355444 return false ;
54365445 }
54375446
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-
54635447 // Assert that the deserialized chainstate contents match the expected assumeutxo value.
54645448
54655449 int base_height = snapshot_start_block->nHeight ;
0 commit comments