Skip to main content

reth_provider/
lib.rs

1//! Collection of traits and trait implementations for common database operations.
2//!
3//! ## Feature Flags
4//!
5//! - `test-utils`: Export utilities for testing
6
7#![doc(
8    html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
9    html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
10    issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
11)]
12#![cfg_attr(not(test), warn(unused_crate_dependencies))]
13#![cfg_attr(docsrs, feature(doc_cfg))]
14
15/// Utility functions for initializing the database.
16pub mod init;
17
18/// Various provider traits.
19mod traits;
20pub use traits::*;
21
22/// Provider trait implementations.
23pub mod providers;
24pub use providers::{
25    DatabaseProvider, DatabaseProviderRO, DatabaseProviderRW, LatestStateProvider,
26    LatestStateProviderRef, ProviderFactory, PruneShardOutcome, PrunedIndices, SaveBlocksInput,
27    StaticFileAccess, StaticFileProviderBuilder, StaticFileWriteCtx, StaticFileWriter,
28};
29
30pub mod changeset_walker;
31pub mod changesets_utils;
32
33#[cfg(any(test, feature = "test-utils"))]
34/// Common test helpers for mocking the Provider.
35pub mod test_utils;
36
37pub mod either_writer;
38pub use either_writer::*;
39
40mod bal;
41pub use bal::{BalConfig, InMemoryBalStore, RocksDBBalStore};
42
43pub use reth_chain_state::{
44    CanonStateNotification, CanonStateNotificationSender, CanonStateNotificationStream,
45    CanonStateNotifications, CanonStateSubscriptions,
46};
47pub use reth_execution_types::*;
48/// Re-export `OriginalValuesKnown`
49pub use revm::database::states::OriginalValuesKnown;
50// reexport traits to avoid breaking changes
51pub use reth_static_file_types as static_file;
52pub use reth_storage_api::{
53    BalNotification, BalNotificationStream, BalProvider, BalStore, BalStoreHandle,
54    GetBlockAccessListLimit, HistoryWriter, MetadataProvider, MetadataWriter, NoopBalStore, RawBal,
55    StateWriteConfig, StatsReader, StorageSettings, StorageSettingsCache,
56};
57/// Re-export provider error.
58pub use reth_storage_errors::provider::{ProviderError, ProviderResult};
59pub use static_file::StaticFileSegment;
60
61/// Converts a [`RangeBounds`](std::ops::RangeBounds) into a concrete [`Range`](std::ops::Range)
62pub fn to_range<R: std::ops::RangeBounds<u64>>(bounds: R) -> std::ops::Range<u64> {
63    let start = match bounds.start_bound() {
64        std::ops::Bound::Included(&v) => v,
65        std::ops::Bound::Excluded(&v) => v + 1,
66        std::ops::Bound::Unbounded => 0,
67    };
68
69    let end = match bounds.end_bound() {
70        std::ops::Bound::Included(&v) => v + 1,
71        std::ops::Bound::Excluded(&v) => v,
72        std::ops::Bound::Unbounded => u64::MAX,
73    };
74
75    start..end
76}