refactor: use `SpanReader` in `TestBlockAndIndex`
What changed, and why it matters
This is a small internal cleanup in Bitcoin Core's benchmarking code. It swaps one way of reading a fixed test block fixture for another, read-only way, and removes a workaround that added a dummy byte. There is no user-facing or security-relevant change.
No security action needed; this is a routine refactor of benchmark-only code.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors TestBlockAndIndex in src/bench/rpc_blockchain.cpp to use SpanReader instead of DataStream for deserializing the benchmark fixture block413567. The previous DataStream path required appending a dummy byte to inhibit compaction after full consumption; SpanReader is read-only and avoids that workaround. The change is confined to benchmark code and does not alter consensus, serialization format, or runtime behavior.
Changed components
src/bench/rpc_blockchain.cppInspect captured patch +1 / −4
diff --git a/src/bench/rpc_blockchain.cpp b/src/bench/rpc_blockchain.cpp
index 0e89ac78..fe83c4a2 100644
--- a/src/bench/rpc_blockchain.cpp
+++ b/src/bench/rpc_blockchain.cpp
@@ -31,10 +31,7 @@ struct TestBlockAndIndex {
TestBlockAndIndex()
{
- DataStream stream{benchmark::data::block413567};
- std::byte a{0};
- stream.write({&a, 1}); // Prevent compaction
-
+ SpanReader stream{benchmark::data::block413567};
stream >> TX_WITH_WITNESS(block);
blockHash = block.GetHash();
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.