MCPcopy Create free account
hub / github.com/base/base / encode_packed

Method encode_packed

crates/batcher/blobs/src/encoder.rs:54–62  ·  view source on GitHub ↗

Pack multiple frames into a single blob payload. Encodes `[DERIVATION_VERSION_0] ++ frame0.encode() ++ frame1.encode() ++ …` into one blob. The derivation pipeline's `Frame::parse_frames` uses a `while offset < len` loop, so all packed frames are decoded correctly.

(frames: &[Arc<Frame>])

Source from the content-addressed store, hash-verified

52 /// into one blob. The derivation pipeline's `Frame::parse_frames` uses a
53 /// `while offset < len` loop, so all packed frames are decoded correctly.
54 pub fn encode_packed(frames: &[Arc<Frame>]) -> Result<Box<Blob>, BlobEncodeError> {
55 let encoded_size: usize = frames.iter().map(|f| Self::FRAME_OVERHEAD + f.data.len()).sum();
56 let mut data = Vec::with_capacity(1 + encoded_size);
57 data.push(DERIVATION_VERSION_0);
58 for frame in frames {
59 data.extend_from_slice(&frame.encode());
60 }
61 Self::encode(&data)
62 }
63
64 /// Encode `data` into a single EIP-4844 [`Blob`].
65 ///

Callers

nothing calls this directly

Calls 6

encodeFunction · 0.85
sumMethod · 0.80
iterMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected