Skip to main content

DBProvider

Trait DBProvider 

Source
pub trait DBProvider: Sized + DbTxProvider {
    // Required methods
    fn tx_mut(&mut self) -> &mut Self::Tx;
    fn into_tx(self) -> Self::Tx;
    fn commit(self) -> Result<(), ProviderError>;
    fn prune_modes_ref(&self) -> &PruneModes;

    // Provided methods
    fn tx_ref(&self) -> &Self::Tx { ... }
    fn disable_long_read_transaction_safety(self) -> Self { ... }
    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 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 { ... }
}
Available on crate features db-api and storage-api only.
Expand description

Database provider.

Required Methods§

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 commit(self) -> Result<(), ProviderError>

Commit database transaction

Source

fn prune_modes_ref(&self) -> &PruneModes

Returns a reference to prune modes.

Provided Methods§

Source

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

Returns a reference to the underlying transaction.

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 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

Source

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.

Source

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.

Source

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.

Source

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".

Implementors§

Source§

impl<ChainSpec, N> DBProvider for NoopProvider<ChainSpec, N>
where ChainSpec: Send + Sync, N: NodePrimitives,

Source§

impl<T, ChainSpec> DBProvider for MockEthProvider<T, ChainSpec>
where T: NodePrimitives, ChainSpec: EthChainSpec + 'static,

Source§

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