Skip to content

Commit 2371b9f

Browse files
committed
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.
1 parent 5d235d5 commit 2371b9f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/bench/readwriteblock.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ static void ReadBlockBench(benchmark::Bench& bench)
4242
{
4343
const auto testing_setup{MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN)};
4444
auto& blockman{testing_setup->m_node.chainman->m_blockman};
45-
const auto pos{blockman.WriteBlock(CreateTestBlock(), 413'567)};
46-
CBlock block;
45+
const auto& test_block{CreateTestBlock()};
46+
const auto& expected_hash{test_block.GetHash()};
47+
const auto& pos{blockman.WriteBlock(test_block, 413'567)};
4748
bench.run([&] {
48-
const auto success{blockman.ReadBlock(block, pos)};
49+
CBlock block;
50+
const auto success{blockman.ReadBlock(block, pos, expected_hash)};
4951
assert(success);
5052
});
5153
}

src/test/util/blockfilter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ bool ComputeFilter(BlockFilterType filter_type, const CBlockIndex& block_index,
1717
LOCK(::cs_main);
1818

1919
CBlock block;
20-
if (!blockman.ReadBlock(block, block_index.GetBlockPos())) {
20+
if (!blockman.ReadBlock(block, block_index)) {
2121
return false;
2222
}
2323

0 commit comments

Comments
 (0)