Skip to content

Commit 17b0dff

Browse files
codexzxch3n
authored andcommitted
docs: clarify checksum ranges in encoding spec
Fix xxHash32 document checksum example to hash bytes[20..] (encode mode + body).\n\nClarify SSTable block meta checksum excludes the initial block count.\n\nCo-authored-by: lody <agent@lody.ai>
1 parent 8be7f39 commit 17b0dff

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

docs/encoding-xxhash32.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ function verifyLoroDocument(bytes) {
164164
// Read stored checksum (bytes 16-20, little-endian)
165165
const storedChecksum = readU32LE(bytes, 16);
166166

167-
// Calculate checksum of body (bytes 22+)
168-
const body = bytes.slice(22);
169-
const calculatedChecksum = xxHash32(body, 0x4F524F4C);
167+
// Calculate checksum of encode_mode + body (bytes 20+)
168+
const payload = bytes.slice(20);
169+
const calculatedChecksum = xxHash32(payload, 0x4F524F4C);
170170

171171
if (storedChecksum !== calculatedChecksum) {
172172
throw new Error("Checksum mismatch");

docs/encoding.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ Both `oplog_bytes` and `state_bytes` use a KV Store format based on SSTable (Sor
222222
│ variable │ last_key (bytes) - only if !is_large │
223223
├───────────────┼─────────────────────────────────────────────────┤
224224
│ 4 │ Checksum (xxHash32, little-endian) │
225-
│ │ Covers all block meta entries
225+
│ │ Covers all block meta entries (excluding count)
226226
└───────────────┴─────────────────────────────────────────────────┘
227227
```
228228

0 commit comments

Comments
 (0)