alloy_consensus

Trait SidecarCoder

Source
pub trait SidecarCoder {
    // Required methods
    fn required_fe(&self, data: &[u8]) -> usize;
    fn code(&mut self, builder: &mut PartialSidecar, data: &[u8]);
    fn finish(self, builder: &mut PartialSidecar);
    fn decode_all(
        &mut self,
        blobs: &[FixedBytes<alloy_eips::::eip4844::Blob::{constant#0}>],
    ) -> Option<Vec<Vec<u8>>>;
}
Expand description

A strategy for coding and decoding data into sidecars.

Coder instances are responsible for encoding and decoding data into and from the sidecar. They are called by the SidecarBuilder during the ingest, take, and (if c_kzg feature enabled) build methods.

This trait allows different downstream users to use different bit-packing strategies. For example, a simple coder might only use the last 31 bytes of each blob, while a more complex coder might use a more sophisticated strategy to pack data into the low 6 bits of the top byte.

Required Methods§

Source

fn required_fe(&self, data: &[u8]) -> usize

Calculate the number of field elements required to store the given data.

Source

fn code(&mut self, builder: &mut PartialSidecar, data: &[u8])

Code a slice of data into the builder.

Source

fn finish(self, builder: &mut PartialSidecar)

Finish the sidecar, and commit to the data. This method should empty any buffer or scratch space in the coder, and is called by SidecarBuilder’s take and build methods.

Source

fn decode_all( &mut self, blobs: &[FixedBytes<alloy_eips::::eip4844::Blob::{constant#0}>], ) -> Option<Vec<Vec<u8>>>

Decode all slices of data from the blobs.

Implementors§