reth::providers

Trait DBProvider

pub trait DBProvider:
    Sized
    + Send
    + Sync
    + '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) -> Result<bool, ProviderError> { ... } fn table<T>( &self, ) -> Result<Vec<(<T as Table>::Key, <T as Table>::Value)>, DatabaseError> where T: Table, <T as Table>::Key: Default + Ord { ... } fn get<T>( &self, range: impl RangeBounds<<T as Table>::Key>, ) -> Result<Vec<(<T as Table>::Key, <T as Table>::Value)>, DatabaseError> where T: Table { ... } fn cursor_read_collect<T>( &self, range: impl RangeBounds<<T as Table>::Key>, ) -> Result<Vec<<T as Table>::Value>, ProviderError> where T: Table<Key = u64> { ... } fn cursor_collect<T>( &self, cursor: &mut impl DbCursorRO<T>, range: impl RangeBounds<<T as Table>::Key>, ) -> Result<Vec<<T as Table>::Value>, ProviderError> where T: Table<Key = u64> { ... } fn cursor_collect_with_capacity<T>( &self, cursor: &mut impl DbCursorRO<T>, range: impl RangeBounds<<T as Table>::Key>, capacity: usize, ) -> Result<Vec<<T as Table>::Value>, ProviderError> where T: Table<Key = u64> { ... } fn remove<T>( &self, range: impl RangeBounds<<T as Table>::Key>, ) -> Result<usize, DatabaseError> where T: Table, Self::Tx: DbTxMut { ... } fn take<T>( &self, range: impl RangeBounds<<T as Table>::Key>, ) -> Result<Vec<(<T as Table>::Key, <T as Table>::Value)>, DatabaseError> where T: Table, Self::Tx: DbTxMut { ... }
}
Expand description

Database provider.

Required Associated Types§

type Tx: DbTx

Underlying database transaction held by the provider.

Required Methods§

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

Returns a reference to the underlying transaction.

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

Returns a mutable reference to the underlying transaction.

fn into_tx(self) -> Self::Tx

Consumes the provider and returns the underlying transaction.

fn prune_modes_ref(&self) -> &PruneModes

Returns a reference to prune modes.

Provided Methods§

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.

fn commit(self) -> Result<bool, ProviderError>

Commit database transaction

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

Return full table as Vec

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

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

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

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.

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

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

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

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

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

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

fn take<T>( &self, range: impl RangeBounds<<T as Table>::Key>, ) -> Result<Vec<(<T as Table>::Key, <T as Table>::Value)>, DatabaseError>
where T: Table, 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§

Source§

impl<TX, N> DBProvider for DatabaseProvider<TX, N>
where TX: DbTx + 'static, N: NodeTypes + 'static,

Source§

type Tx = TX