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:
1 parent
5d235d50d6
commit
2371b9f4ee
2 files changed
+6
-4
No files matched your search
@@ -42,10 +42,12 @@ static void ReadBlockBench(benchmark::Bench& bench)
|
|||||||
{
|
{
|
||||||
const auto testing_setup{MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN)};
|
const auto testing_setup{MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN)};
|
||||||
auto& blockman{testing_setup->m_node.chainman->m_blockman};
|
auto& blockman{testing_setup->m_node.chainman->m_blockman};
|
||||||
const auto pos{blockman.WriteBlock(CreateTestBlock(), 413'567)};
|
const auto& test_block{CreateTestBlock()};
|
||||||
CBlock block;
|
const auto& expected_hash{test_block.GetHash()};
|
||||||
|
const auto& pos{blockman.WriteBlock(test_block, 413'567)};
|
||||||
bench.run([&] {
|
bench.run([&] {
|
||||||
const auto success{blockman.ReadBlock(block, pos)};
|
CBlock block;
|
||||||
|
const auto success{blockman.ReadBlock(block, pos, expected_hash)};
|
||||||
assert(success);
|
assert(success);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ bool ComputeFilter(BlockFilterType filter_type, const CBlockIndex& block_index,
|
|||||||
LOCK(::cs_main);
|
LOCK(::cs_main);
|
||||||
|
|
||||||
CBlock block;
|
CBlock block;
|
||||||
if (!blockman.ReadBlock(block, block_index.GetBlockPos())) {
|
if (!blockman.ReadBlock(block, block_index)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user