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§
Sourcefn insert(
&self,
num_hash: NumHash,
bal: Sealed<Bytes>,
) -> Result<(), ProviderError>
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.
Sourcefn prune(&self, tip: u64) -> Result<usize, ProviderError>
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.
Sourcefn get_by_hashes(
&self,
block_hashes: &[FixedBytes<32>],
) -> Result<Vec<Option<Bytes>>, ProviderError>
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.
Sourcefn get_by_range(
&self,
start: u64,
count: u64,
) -> Result<Vec<Bytes>, ProviderError>
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.
Sourcefn bal_stream(&self) -> EventStream<BalNotification>
Available on crate feature std only.
fn bal_stream(&self) -> EventStream<BalNotification>
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§
Sourcefn insert_many(
&self,
entries: Vec<(NumHash, Sealed<Bytes>)>,
) -> Result<(), ProviderError>
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.
Sourcefn flush(&self) -> Result<(), ProviderError>
fn flush(&self) -> Result<(), ProviderError>
Flushes any pending BALs to the backing store.
In-memory implementations may treat this as a no-op.
Sourcefn get_by_hash(
&self,
block_hash: FixedBytes<32>,
) -> Result<Option<Bytes>, ProviderError>
fn get_by_hash( &self, block_hash: FixedBytes<32>, ) -> Result<Option<Bytes>, ProviderError>
Fetches the BAL for the given block hash.
Sourcefn get_decoded_by_hash(
&self,
block_hash: FixedBytes<32>,
) -> Result<Option<DecodedBal>, ProviderError>
fn get_decoded_by_hash( &self, block_hash: FixedBytes<32>, ) -> Result<Option<DecodedBal>, ProviderError>
Fetches and decodes the BAL for the given block hash.
Sourcefn revm_bal_by_hash(
&self,
block_hash: FixedBytes<32>,
) -> Result<Option<DecodedBal<Bal>>, ProviderError>
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.
Sourcefn get_by_hashes_with_limit(
&self,
block_hashes: &[FixedBytes<32>],
limit: GetBlockAccessListLimit,
) -> Result<Vec<Option<Bytes>>, ProviderError>
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.
Sourcefn append_by_hashes_with_limit(
&self,
block_hashes: &[FixedBytes<32>],
limit: GetBlockAccessListLimit,
out: &mut Vec<Option<Bytes>>,
) -> Result<(), ProviderError>
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
impl<'a, T> BalStore for &'a T
fn insert( &self, num_hash: NumHash, bal: Sealed<Bytes>, ) -> Result<(), ProviderError>
fn insert_many( &self, entries: Vec<(NumHash, Sealed<Bytes>)>, ) -> Result<(), ProviderError>
fn flush(&self) -> 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_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>
fn get_by_range( &self, start: u64, count: u64, ) -> Result<Vec<Bytes>, ProviderError>
Source§fn bal_stream(&self) -> EventStream<BalNotification>
fn bal_stream(&self) -> EventStream<BalNotification>
std only.Source§impl<T> BalStore for Box<T>
impl<T> BalStore for Box<T>
fn insert( &self, num_hash: NumHash, bal: Sealed<Bytes>, ) -> Result<(), ProviderError>
fn insert_many( &self, entries: Vec<(NumHash, Sealed<Bytes>)>, ) -> Result<(), ProviderError>
fn flush(&self) -> 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_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>
fn get_by_range( &self, start: u64, count: u64, ) -> Result<Vec<Bytes>, ProviderError>
Source§fn bal_stream(&self) -> EventStream<BalNotification>
fn bal_stream(&self) -> EventStream<BalNotification>
std only.Source§impl<T> BalStore for Arc<T>
impl<T> BalStore for Arc<T>
fn insert( &self, num_hash: NumHash, bal: Sealed<Bytes>, ) -> Result<(), ProviderError>
fn insert_many( &self, entries: Vec<(NumHash, Sealed<Bytes>)>, ) -> Result<(), ProviderError>
fn flush(&self) -> 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_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>
fn get_by_range( &self, start: u64, count: u64, ) -> Result<Vec<Bytes>, ProviderError>
Source§fn bal_stream(&self) -> EventStream<BalNotification>
fn bal_stream(&self) -> EventStream<BalNotification>
std only.