reth_storage_api

Trait DBProvider

Source
pub trait DBProvider:
    Send
    + Sync
    + Sized
    + 'static {
    type Tx: DbTx;

Show 13 methods // Required methods fn tx_ref(&self) -> &Self::Tx; fn tx_mut(&mut self) -> &mut Self::Tx; fn into_tx(self) -> Self::Tx; fn prune_modes_ref(&self) -> &PruneModes; // Provided methods fn disable_long_read_transaction_safety(self) -> Self { ... } fn commit(self) -> ProviderResult<bool> { ... } fn table<T: Table>(&self) -> Result<Vec<KeyValue<T>>, DatabaseError> where T::Key: Default + Ord { ... } fn get<T: Table>( &self, range: impl RangeBounds<T::Key>, ) -> Result<Vec<KeyValue<T>>, DatabaseError> { ... } fn cursor_read_collect<T: Table<Key = u64>>( &self, range: impl RangeBounds<T::Key>, ) -> ProviderResult<Vec<T::Value>> { ... } fn cursor_collect<T: Table<Key = u64>>( &self, cursor: &mut impl DbCursorRO<T>, range: impl RangeBounds<T::Key>, ) -> ProviderResult<Vec<T::Value>> { ... } fn cursor_collect_with_capacity<T: Table<Key = u64>>( &self, cursor: &mut impl DbCursorRO<T>, range: impl RangeBounds<T::Key>, capacity: usize, ) -> ProviderResult<Vec<T::Value>> { ... } fn remove<T: Table>( &self, range: impl RangeBounds<T::Key>, ) -> Result<usize, DatabaseError> where Self::Tx: DbTxMut { ... } fn take<T: Table>( &self, range: impl RangeBounds<T::Key>, ) -> Result<Vec<KeyValue<T>>, DatabaseError> where Self::Tx: DbTxMut { ... }
}
Expand description

Database provider.

Required Associated Types§

Source

type Tx: DbTx

Underlying database transaction held by the provider.

Required Methods§

Source

fn tx_ref(&self) -> &Self::Tx

Returns a reference to the underlying transaction.

Source

fn tx_mut(&mut self) -> &mut Self::Tx

Returns a mutable reference to the underlying transaction.

Source

fn into_tx(self) -> Self::Tx

Consumes the provider and returns the underlying transaction.

Source

fn prune_modes_ref(&self) -> &PruneModes

Returns a reference to prune modes.

Provided Methods§

Source

fn disable_long_read_transaction_safety(self) -> Self

Disables long-lived read transaction safety guarantees for leaks prevention and observability improvements.

CAUTION: In most of the cases, you want the safety guarantees for long read transactions enabled. Use this only if you’re sure that no write transaction is open in parallel, meaning that Reth as a node is offline and not progressing.

Source

fn commit(self) -> ProviderResult<bool>

Commit database transaction

Source

fn table<T: Table>(&self) -> Result<Vec<KeyValue<T>>, DatabaseError>
where T::Key: Default + Ord,

Return full table as Vec

Source

fn get<T: Table>( &self, range: impl RangeBounds<T::Key>, ) -> Result<Vec<KeyValue<T>>, DatabaseError>

Return a list of entries from the table, based on the given range.

Source

fn cursor_read_collect<T: Table<Key = u64>>( &self, range: impl RangeBounds<T::Key>, ) -> ProviderResult<Vec<T::Value>>

Iterates over read only values in the given table and collects them into a vector.

Early-returns if the range is empty, without opening a cursor transaction.

Source

fn cursor_collect<T: Table<Key = u64>>( &self, cursor: &mut impl DbCursorRO<T>, range: impl RangeBounds<T::Key>, ) -> ProviderResult<Vec<T::Value>>

Iterates over read only values in the given table and collects them into a vector.

Source

fn cursor_collect_with_capacity<T: Table<Key = u64>>( &self, cursor: &mut impl DbCursorRO<T>, range: impl RangeBounds<T::Key>, capacity: usize, ) -> ProviderResult<Vec<T::Value>>

Iterates over read only values in the given table and collects them into a vector with capacity.

Source

fn remove<T: Table>( &self, range: impl RangeBounds<T::Key>, ) -> Result<usize, DatabaseError>
where Self::Tx: DbTxMut,

Remove list of entries from the table. Returns the number of entries removed.

Source

fn take<T: Table>( &self, range: impl RangeBounds<T::Key>, ) -> Result<Vec<KeyValue<T>>, DatabaseError>
where Self::Tx: DbTxMut,

Return a list of entries from the table, and remove them, based on the given range.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§