Skip to main content

BalStore

Trait BalStore 

Source
pub trait BalStore:
    Send
    + Sync
    + 'static {
    // Required methods
    fn insert(
        &self,
        num_hash: NumHash,
        bal: Sealed<Bytes>,
    ) -> Result<(), ProviderError>;
    fn prune(&self, tip: u64) -> Result<usize, ProviderError>;
    fn get_by_hashes(
        &self,
        block_hashes: &[FixedBytes<32>],
    ) -> Result<Vec<Option<Bytes>>, ProviderError>;
    fn get_by_range(
        &self,
        start: u64,
        count: u64,
    ) -> Result<Vec<Bytes>, ProviderError>;
    fn bal_stream(&self) -> EventStream<BalNotification>;

    // Provided methods
    fn insert_many(
        &self,
        entries: Vec<(NumHash, Sealed<Bytes>)>,
    ) -> Result<(), ProviderError> { ... }
    fn flush(&self) -> Result<(), ProviderError> { ... }
    fn get_by_hash(
        &self,
        block_hash: FixedBytes<32>,
    ) -> Result<Option<Bytes>, ProviderError> { ... }
    fn get_decoded_by_hash(
        &self,
        block_hash: FixedBytes<32>,
    ) -> Result<Option<DecodedBal>, ProviderError> { ... }
    fn revm_bal_by_hash(
        &self,
        block_hash: FixedBytes<32>,
    ) -> Result<Option<DecodedBal<Bal>>, ProviderError> { ... }
    fn get_by_hashes_with_limit(
        &self,
        block_hashes: &[FixedBytes<32>],
        limit: GetBlockAccessListLimit,
    ) -> Result<Vec<Option<Bytes>>, ProviderError> { ... }
    fn append_by_hashes_with_limit(
        &self,
        block_hashes: &[FixedBytes<32>],
        limit: GetBlockAccessListLimit,
        out: &mut Vec<Option<Bytes>>,
    ) -> Result<(), ProviderError> { ... }
}
Expand description

Store for Block Access Lists (BALs).

This abstraction intentionally does not prescribe where BALs live. Implementations may keep recent BALs in memory, read canonical BALs from static files, or compose multiple tiers behind a single interface.

Required Methods§

Source

fn insert( &self, num_hash: NumHash, bal: Sealed<Bytes>, ) -> Result<(), ProviderError>

Insert the BAL for the given block.

Implementations may buffer inserts. Call Self::flush when pending BALs need to be made durable.

Source

fn prune(&self, tip: u64) -> Result<usize, ProviderError>

Prunes expired BALs according to the store’s retention policy and the given chain tip.

Returns the number of BALs pruned.

Source

fn get_by_hashes( &self, block_hashes: &[FixedBytes<32>], ) -> Result<Vec<Option<Bytes>>, ProviderError>

Fetch BALs for the given block hashes.

The returned vector must align with block_hashes.

Source

fn get_by_range( &self, start: u64, count: u64, ) -> Result<Vec<Bytes>, ProviderError>

Fetch BALs for the requested range.

Implementations may stop at the first gap and return the contiguous prefix.

Source

fn bal_stream(&self) -> EventStream<BalNotification>

Available on crate feature std only.

Returns a stream of BAL insert notifications.

Notifications are emitted only after a BAL has been successfully inserted into the store. They do not imply canonicality.

Provided Methods§

Source

fn insert_many( &self, entries: Vec<(NumHash, Sealed<Bytes>)>, ) -> Result<(), ProviderError>

Insert multiple BALs.

The default implementation preserves the behavior of repeated Self::insert calls.

Source

fn flush(&self) -> Result<(), ProviderError>

Flushes any pending BALs to the backing store.

In-memory implementations may treat this as a no-op.

Source

fn get_by_hash( &self, block_hash: FixedBytes<32>, ) -> Result<Option<Bytes>, ProviderError>

Fetches the BAL for the given block hash.

Source

fn get_decoded_by_hash( &self, block_hash: FixedBytes<32>, ) -> Result<Option<DecodedBal>, ProviderError>

Fetches and decodes the BAL for the given block hash.

Source

fn revm_bal_by_hash( &self, block_hash: FixedBytes<32>, ) -> Result<Option<DecodedBal<Bal>>, ProviderError>

Fetches the BAL for the given block hash in revm representation.

Source

fn get_by_hashes_with_limit( &self, block_hashes: &[FixedBytes<32>], limit: GetBlockAccessListLimit, ) -> Result<Vec<Option<Bytes>>, ProviderError>

Fetch BAL response entries for the given block hashes, stopping after the soft limit is exceeded.

Entries are returned in request order. Unavailable BALs are represented as None. The limit is soft: the entry that exceeds the limit is included.

Source

fn append_by_hashes_with_limit( &self, block_hashes: &[FixedBytes<32>], limit: GetBlockAccessListLimit, out: &mut Vec<Option<Bytes>>, ) -> Result<(), ProviderError>

Extends the given vector with BAL response entries for the given hashes.

This adheres to the expected behavior of Self::get_by_hashes_with_limit.

Implementations on Foreign Types§

Source§

impl<'a, T> BalStore for &'a T
where T: 'a + BalStore + ?Sized, &'a T: Send + Sync + 'static,

Source§

fn insert( &self, num_hash: NumHash, bal: Sealed<Bytes>, ) -> Result<(), ProviderError>

Source§

fn insert_many( &self, entries: Vec<(NumHash, Sealed<Bytes>)>, ) -> Result<(), ProviderError>

Source§

fn flush(&self) -> Result<(), ProviderError>

Source§

fn prune(&self, tip: u64) -> Result<usize, ProviderError>

Source§

fn get_by_hashes( &self, block_hashes: &[FixedBytes<32>], ) -> Result<Vec<Option<Bytes>>, ProviderError>

Source§

fn get_by_hash( &self, block_hash: FixedBytes<32>, ) -> Result<Option<Bytes>, ProviderError>

Source§

fn get_decoded_by_hash( &self, block_hash: FixedBytes<32>, ) -> Result<Option<DecodedBal>, ProviderError>

Source§

fn revm_bal_by_hash( &self, block_hash: FixedBytes<32>, ) -> Result<Option<DecodedBal<Bal>>, ProviderError>

Source§

fn get_by_hashes_with_limit( &self, block_hashes: &[FixedBytes<32>], limit: GetBlockAccessListLimit, ) -> Result<Vec<Option<Bytes>>, ProviderError>

Source§

fn append_by_hashes_with_limit( &self, block_hashes: &[FixedBytes<32>], limit: GetBlockAccessListLimit, out: &mut Vec<Option<Bytes>>, ) -> Result<(), ProviderError>

Source§

fn get_by_range( &self, start: u64, count: u64, ) -> Result<Vec<Bytes>, ProviderError>

Source§

fn bal_stream(&self) -> EventStream<BalNotification>

Available on crate feature std only.
Source§

impl<T> BalStore for Box<T>
where T: BalStore + ?Sized, Box<T>: Send + Sync + 'static,

Source§

fn insert( &self, num_hash: NumHash, bal: Sealed<Bytes>, ) -> Result<(), ProviderError>

Source§

fn insert_many( &self, entries: Vec<(NumHash, Sealed<Bytes>)>, ) -> Result<(), ProviderError>

Source§

fn flush(&self) -> Result<(), ProviderError>

Source§

fn prune(&self, tip: u64) -> Result<usize, ProviderError>

Source§

fn get_by_hashes( &self, block_hashes: &[FixedBytes<32>], ) -> Result<Vec<Option<Bytes>>, ProviderError>

Source§

fn get_by_hash( &self, block_hash: FixedBytes<32>, ) -> Result<Option<Bytes>, ProviderError>

Source§

fn get_decoded_by_hash( &self, block_hash: FixedBytes<32>, ) -> Result<Option<DecodedBal>, ProviderError>

Source§

fn revm_bal_by_hash( &self, block_hash: FixedBytes<32>, ) -> Result<Option<DecodedBal<Bal>>, ProviderError>

Source§

fn get_by_hashes_with_limit( &self, block_hashes: &[FixedBytes<32>], limit: GetBlockAccessListLimit, ) -> Result<Vec<Option<Bytes>>, ProviderError>

Source§

fn append_by_hashes_with_limit( &self, block_hashes: &[FixedBytes<32>], limit: GetBlockAccessListLimit, out: &mut Vec<Option<Bytes>>, ) -> Result<(), ProviderError>

Source§

fn get_by_range( &self, start: u64, count: u64, ) -> Result<Vec<Bytes>, ProviderError>

Source§

fn bal_stream(&self) -> EventStream<BalNotification>

Available on crate feature std only.
Source§

impl<T> BalStore for Arc<T>
where T: BalStore + ?Sized, Arc<T>: Send + Sync + 'static,

Source§

fn insert( &self, num_hash: NumHash, bal: Sealed<Bytes>, ) -> Result<(), ProviderError>

Source§

fn insert_many( &self, entries: Vec<(NumHash, Sealed<Bytes>)>, ) -> Result<(), ProviderError>

Source§

fn flush(&self) -> Result<(), ProviderError>

Source§

fn prune(&self, tip: u64) -> Result<usize, ProviderError>

Source§

fn get_by_hashes( &self, block_hashes: &[FixedBytes<32>], ) -> Result<Vec<Option<Bytes>>, ProviderError>

Source§

fn get_by_hash( &self, block_hash: FixedBytes<32>, ) -> Result<Option<Bytes>, ProviderError>

Source§

fn get_decoded_by_hash( &self, block_hash: FixedBytes<32>, ) -> Result<Option<DecodedBal>, ProviderError>

Source§

fn revm_bal_by_hash( &self, block_hash: FixedBytes<32>, ) -> Result<Option<DecodedBal<Bal>>, ProviderError>

Source§

fn get_by_hashes_with_limit( &self, block_hashes: &[FixedBytes<32>], limit: GetBlockAccessListLimit, ) -> Result<Vec<Option<Bytes>>, ProviderError>

Source§

fn append_by_hashes_with_limit( &self, block_hashes: &[FixedBytes<32>], limit: GetBlockAccessListLimit, out: &mut Vec<Option<Bytes>>, ) -> Result<(), ProviderError>

Source§

fn get_by_range( &self, start: u64, count: u64, ) -> Result<Vec<Bytes>, ProviderError>

Source§

fn bal_stream(&self) -> EventStream<BalNotification>

Available on crate feature std only.

Implementors§