replaces the magic number 6 in the trailer boundary condition with kHeaderSize and corrects an off-by-one by expressing the rule as offset_in_block > kBlockSize - kHeaderSize, which is equivalent to offset_in_block >= kBlockSize - 6. According to src/leveldb/doc/log_format.md: “A record never starts within the last six bytes of a block” and when exactly seven bytes remain a record may start (e.g., a zero-length FIRST), so the equal case must be treated as trailer. The writer already uses kHeaderSize to manage trailers, and aligning the reader with kHeaderSize removes a format-coupled magic number and ensures future-proof consistency. Functionally this avoids scanning a block when initial_offset_ is in the last six bytes, matching the documented format; it was previously a minor inefficiency and comment mismatch rather than a correctness issue.
leveldb: correct trailer boundary check in Reader::SkipToInitialBlock #33955
pull sashass1315 wants to merge 1 commits into bitcoin:master from sashass1315:fix/log-reader-trailer-boundary changing 1 files +1 −1-
sashass1315 commented at 7:13 PM on November 26, 2025: none
-
leveldb: correct trailer boundary check in Reader::SkipToInitialBlock 91faa93c17
-
DrahtBot commented at 7:13 PM on November 26, 2025: contributor
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--006a51241073e994b41acfe9ec718e94-->
Code Coverage & Benchmarks
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33955.
<!--021abf342d371248e50ceaed478a90ca-->
Reviews
See the guideline for information on the review process. A summary of reviews will appear here.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
-
maflcko commented at 8:03 AM on November 27, 2025: member
thx, but this will need to go upstream
- maflcko closed this on Nov 27, 2025
Contributors