alloy_consensus

Struct SidecarBuilder

Source
pub struct SidecarBuilder<T = SimpleCoder> { /* private fields */ }
Expand description

Build a BlobTransactionSidecar from an arbitrary amount of data.

This is useful for creating a sidecar from a large amount of data, which is then split into blobs. It delays KZG commitments and proofs until all data is ready.

Implementations§

Source§

impl<'a, T> SidecarBuilder<T>
where T: Arbitrary<'a> + Clone,

Source

pub fn build_arbitrary(&self) -> BlobTransactionSidecar

Available on crate feature arbitrary only.

Builds an arbitrary realization for BlobTransactionSidecar.

Source§

impl<T> SidecarBuilder<T>
where T: SidecarCoder + Default,

Source

pub fn new() -> SidecarBuilder<T>

Instantiate a new builder and new coder instance.

By default, this allocates space for 2 blobs (256 KiB). If you want to preallocate a specific number of blobs, use SidecarBuilder::with_capacity.

Source

pub fn from_slice(data: &[u8]) -> SidecarBuilder<T>

Create a new builder from a slice of data by calling SidecarBuilder::from_coder_and_data

Source

pub fn with_capacity(capacity: usize) -> SidecarBuilder<T>

Create a new builder with a pre-allocated capacity. This capacity is measured in blobs, each of which is 128 KiB.

Source§

impl<T> SidecarBuilder<T>
where T: SidecarCoder,

Source

pub fn from_coder_and_capacity(coder: T, capacity: usize) -> SidecarBuilder<T>

Instantiate a new builder with the provided coder and capacity. This capacity is measured in blobs, each of which is 128 KiB.

Source

pub const fn len(&self) -> usize

Calculate the length of bytes used by field elements in the builder.

This is always strictly greater than the number of bytes that have been ingested.

Source

pub const fn is_empty(&self) -> bool

Check if the builder is empty.

Source

pub fn from_coder_and_data(coder: T, data: &[u8]) -> SidecarBuilder<T>

Create a new builder from a slice of data.

Source

pub fn ingest(&mut self, data: &[u8])

Ingest a slice of data into the builder.

Source

pub fn build_with_settings( self, settings: &KZGSettings, ) -> Result<BlobTransactionSidecar, Error>

Available on crate feature kzg only.

Build the sidecar from the data with the provided settings.

Source

pub fn build(self) -> Result<BlobTransactionSidecar, Error>

Available on crate feature kzg only.

Build the sidecar from the data, with default (Ethereum Mainnet) settings.

Source

pub fn take(self) -> Vec<FixedBytes<alloy_eips::::eip4844::Blob::{constant#0}>>

Take the blobs from the builder, without committing them to a KZG proof.

Trait Implementations§

Source§

impl<T> Clone for SidecarBuilder<T>
where T: Clone,

Source§

fn clone(&self) -> SidecarBuilder<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for SidecarBuilder<T>
where T: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T> Default for SidecarBuilder<T>
where T: Default + SidecarCoder,

Source§

fn default() -> SidecarBuilder<T>

Returns the “default value” for a type. Read more
Source§

impl<T> From<T> for SidecarBuilder<T>
where T: SidecarCoder,

Source§

fn from(coder: T) -> SidecarBuilder<T>

Instantiate a new builder with the provided coder.

This is equivalent to calling SidecarBuilder::from_coder_and_capacity with a capacity of 1. If you want to preallocate a specific number of blobs, use SidecarBuilder::from_coder_and_capacity.

Source§

impl<T, R> FromIterator<R> for SidecarBuilder<T>
where T: SidecarCoder + Default, R: AsRef<[u8]>,

Source§

fn from_iter<I>(iter: I) -> SidecarBuilder<T>
where I: IntoIterator<Item = R>,

Creates a value from an iterator. Read more

Auto Trait Implementations§

§

impl<T> Freeze for SidecarBuilder<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for SidecarBuilder<T>
where T: RefUnwindSafe,

§

impl<T> Send for SidecarBuilder<T>
where T: Send,

§

impl<T> Sync for SidecarBuilder<T>
where T: Sync,

§

impl<T> Unpin for SidecarBuilder<T>
where T: Unpin,

§

impl<T> UnwindSafe for SidecarBuilder<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V