blockstorage: make block read hash checks explicit

Dropped the default expected_hash parameter from `ReadBlock()`.

In `blockmanager_flush_block_file` tests, we pass {} since the tests would already fail at PoW validation for corrupted blocks.

In `ChainstateManager::LoadExternalBlockFile`, we pass {} when processing child blocks because their hashes aren't known beforehand.
This commit is contained in:
Lőrinc
2025-05-28 14:12:04 +02:00
parent 2371b9f4ee
commit 9341b5333a
3 changed files with 8 additions and 8 deletions

View File

@@ -5168,14 +5168,14 @@ void ChainstateManager::LoadExternalBlockFile(
while (range.first != range.second) {
std::multimap<uint256, FlatFilePos>::iterator it = range.first;
std::shared_ptr<CBlock> pblockrecursive = std::make_shared<CBlock>();
if (m_blockman.ReadBlock(*pblockrecursive, it->second)) {
LogDebug(BCLog::REINDEX, "%s: Processing out of order child %s of %s\n", __func__, pblockrecursive->GetHash().ToString(),
head.ToString());
if (m_blockman.ReadBlock(*pblockrecursive, it->second, {})) {
const auto& block_hash{pblockrecursive->GetHash()};
LogDebug(BCLog::REINDEX, "%s: Processing out of order child %s of %s", __func__, block_hash.ToString(), head.ToString());
LOCK(cs_main);
BlockValidationState dummy;
if (AcceptBlock(pblockrecursive, dummy, nullptr, true, &it->second, nullptr, true)) {
nLoaded++;
queue.push_back(pblockrecursive->GetHash());
queue.push_back(block_hash);
}
}
range.first++;