Skip to main content

BalStore

Trait BalStore 

Source
pub trait BalStore:
    Send
    + Sync
    + 'static {
    // Required methods
    fn insert(
        &self,
        block_hash: BlockHash,
        block_number: BlockNumber,
        bal: Bytes,
    ) -> ProviderResult<()>;
    fn get_by_hashes(
        &self,
        block_hashes: &[BlockHash],
    ) -> ProviderResult<Vec<Option<Bytes>>>;
    fn get_by_range(
        &self,
        start: BlockNumber,
        count: u64,
    ) -> ProviderResult<Vec<Bytes>>;

    // Provided methods
    fn get_by_hashes_with_limit(
        &self,
        block_hashes: &[BlockHash],
        limit: GetBlockAccessListLimit,
    ) -> ProviderResult<Vec<Bytes>> { ... }
    fn append_by_hashes_with_limit(
        &self,
        block_hashes: &[BlockHash],
        limit: GetBlockAccessListLimit,
        out: &mut Vec<Bytes>,
    ) -> ProviderResult<()> { ... }
}
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, block_hash: BlockHash, block_number: BlockNumber, bal: Bytes, ) -> ProviderResult<()>

Insert the BAL for the given block.

Source

fn get_by_hashes( &self, block_hashes: &[BlockHash], ) -> ProviderResult<Vec<Option<Bytes>>>

Fetch BALs for the given block hashes.

The returned vector must align with block_hashes.

Source

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

Fetch BALs for the requested range.

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

Provided Methods§

Source

fn get_by_hashes_with_limit( &self, block_hashes: &[BlockHash], limit: GetBlockAccessListLimit, ) -> ProviderResult<Vec<Bytes>>

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 an RLP-encoded empty list (0xc0). The limit is soft: the entry that exceeds the limit is included.

Source

fn append_by_hashes_with_limit( &self, block_hashes: &[BlockHash], limit: GetBlockAccessListLimit, out: &mut Vec<Bytes>, ) -> ProviderResult<()>

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: 'a + BalStore + ?Sized> BalStore for &'a T
where &'a T: Send + Sync + 'static,

Source§

fn insert( &self, block_hash: BlockHash, block_number: BlockNumber, bal: Bytes, ) -> ProviderResult<()>

Source§

fn get_by_hashes( &self, block_hashes: &[BlockHash], ) -> ProviderResult<Vec<Option<Bytes>>>

Source§

fn get_by_hashes_with_limit( &self, block_hashes: &[BlockHash], limit: GetBlockAccessListLimit, ) -> ProviderResult<Vec<Bytes>>

Source§

fn append_by_hashes_with_limit( &self, block_hashes: &[BlockHash], limit: GetBlockAccessListLimit, out: &mut Vec<Bytes>, ) -> ProviderResult<()>

Source§

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

Source§

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

Source§

fn insert( &self, block_hash: BlockHash, block_number: BlockNumber, bal: Bytes, ) -> ProviderResult<()>

Source§

fn get_by_hashes( &self, block_hashes: &[BlockHash], ) -> ProviderResult<Vec<Option<Bytes>>>

Source§

fn get_by_hashes_with_limit( &self, block_hashes: &[BlockHash], limit: GetBlockAccessListLimit, ) -> ProviderResult<Vec<Bytes>>

Source§

fn append_by_hashes_with_limit( &self, block_hashes: &[BlockHash], limit: GetBlockAccessListLimit, out: &mut Vec<Bytes>, ) -> ProviderResult<()>

Source§

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

Source§

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

Source§

fn insert( &self, block_hash: BlockHash, block_number: BlockNumber, bal: Bytes, ) -> ProviderResult<()>

Source§

fn get_by_hashes( &self, block_hashes: &[BlockHash], ) -> ProviderResult<Vec<Option<Bytes>>>

Source§

fn get_by_hashes_with_limit( &self, block_hashes: &[BlockHash], limit: GetBlockAccessListLimit, ) -> ProviderResult<Vec<Bytes>>

Source§

fn append_by_hashes_with_limit( &self, block_hashes: &[BlockHash], limit: GetBlockAccessListLimit, out: &mut Vec<Bytes>, ) -> ProviderResult<()>

Source§

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

Implementors§