Expand description
§Forest CAR format
See crate::db::car::plain for details on the CAR format.
The forest.car.zst format wraps multiple CAR blocks in small (usually 8 KiB)
zstd frames, and has an index in one or more skippable zstd frames (each
skippable frame contains up to u32::MAX bytes). At the end of the data, there
has to be a fixed-size skippable frame containing magic numbers and meta
information about the archive. CAR blocks may not span multiple z-frames
and the CAR header is kept it a separate z-frame.
Imagine a forest.car.zst archive with 5 blocks. They could be arranged in
z-frames as drawn below:
Z-Frame 1 Z-Frame 2 Z-Frame 3 Skip Frames Skip Frame
┌─────────┐ ┌─────────┐ ┌─────────┐ ┌───────────┐ ┌────────────┐
│┌──────┐ │ │┌───────┐│ │┌───────┐│ │Offsets │ │Index offset│
││Header│ │ ││Block 1││ ││Block 4││ │ Z-Frame 2 │ │Magic number│
│└──────┘ │ │└───────┘│ │└───────┘│ │ Z-Frame 2 │ │Version info|
└─────────┘ │┌───────┐│ │┌───────┐│ │ Z-Frame 2 │ └────────────┘
││Block 2││ ││Block 5││ │ Z-Frame 3 │
│└───────┘│ │└───────┘│ │ Z-Frame 3 │
│┌───────┐│ └─────────┘ └───────────┘
││Block 3││
│└───────┘│
└─────────┘Looking up a block uses an index::Reader to find
the right z-frame. The frame is then decoded and each block is linearly
scanned until a match is found. Decoded (and scanned) z-frames are stored in
a cache for faster repeat retrievals.
forest.car.zst files are backward compatible with Lotus (and all other
tools that consume compressed CAR files). All Forest-specifc information is
encoded as skippable frames that are (as the name suggests) skipped by tools
that don’t understand them.
§Additional reading
zstd frame format: https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md
skippable zstd frames: https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#skippable-frames
CARv1 specification: https://ipld.io/specs/transport/car/carv1/
Modules§
- index 🔒
- Embedded index for the
.forest.car.zstformat.
Structs§
Constants§
- ASYNC_
OPS_ 🔒TIMEOUT - Timeout applied to each async I/O operation of the snapshot export pipeline so that a
stalled reader or writer surfaces as an error instead of wedging the export forever
while
Forest.ChainExportStatuskeeps reporting it as in progress. - DEFAULT_
FOREST_ CAR_ COMPRESSION_ LEVEL - DEFAULT_
FOREST_ CAR_ FRAME_ SIZE - FOREST_
CAR_ FILE_ EXTENSION - TEMP_
FOREST_ CAR_ FILE_ EXTENSION - ZSTD_
SKIPPABLE_ FRAME_ MAGIC_ HEADER - https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#skippable-frames
- ZSTD_
SKIP_ FRAME_ LEN
Functions§
- compressed_
len 🔒 - decode_
zstd_ 🔒single_ frame - finalize_
frame - forest_
car_ sha256sum_ path - forest_
car_ with_ filename_ suffix - invalid_
data 🔒 - new_
encoder - new_
forest_ car_ temp_ path_ in - tmp_
exporting_ forest_ car_ path
Type Aliases§
- Forest
CarFrame zstdframe of Forest CAR