mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-09-07 19:40:46 +02:00
test/bench: verify hash in ComputeFilter
reads
Switch to the index-aware `ReadBlock()` overload in `ComputeFilter` so that filter creation will abort if the stored block header hash doesn't match the expected one. In the `readwriteblock` benchmark, pass the expected hash to `ReadBlock()` to match the new signature without affecting benchmark performance.
This commit is contained in:
@@ -42,10 +42,12 @@ static void ReadBlockBench(benchmark::Bench& bench)
|
||||
{
|
||||
const auto testing_setup{MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN)};
|
||||
auto& blockman{testing_setup->m_node.chainman->m_blockman};
|
||||
const auto pos{blockman.WriteBlock(CreateTestBlock(), 413'567)};
|
||||
CBlock block;
|
||||
const auto& test_block{CreateTestBlock()};
|
||||
const auto& expected_hash{test_block.GetHash()};
|
||||
const auto& pos{blockman.WriteBlock(test_block, 413'567)};
|
||||
bench.run([&] {
|
||||
const auto success{blockman.ReadBlock(block, pos)};
|
||||
CBlock block;
|
||||
const auto success{blockman.ReadBlock(block, pos, expected_hash)};
|
||||
assert(success);
|
||||
});
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ bool ComputeFilter(BlockFilterType filter_type, const CBlockIndex& block_index,
|
||||
LOCK(::cs_main);
|
||||
|
||||
CBlock block;
|
||||
if (!blockman.ReadBlock(block, block_index.GetBlockPos())) {
|
||||
if (!blockman.ReadBlock(block, block_index)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user