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, HistoricalStateProvider,
26    HistoricalStateProviderRef, LatestStateProvider, LatestStateProviderRef, ProviderFactory,
27    PruneShardOutcome, PrunedIndices, SaveBlocksMode, StaticFileAccess, StaticFileProviderBuilder,
28    StaticFileWriteCtx, StaticFileWriter,
29};
30
31pub mod changeset_walker;
32pub mod changesets_utils;
33
34#[cfg(any(test, feature = "test-utils"))]
35/// Common test helpers for mocking the Provider.
36pub mod test_utils;
37
38pub mod either_writer;
39pub use either_writer::*;
40
41mod bal;
42pub use bal::{BalConfig, InMemoryBalStore};
43
44pub use reth_chain_state::{
45    CanonStateNotification, CanonStateNotificationSender, CanonStateNotificationStream,
46    CanonStateNotifications, CanonStateSubscriptions,
47};
48pub use reth_execution_types::*;
49/// Re-export `OriginalValuesKnown`
50pub use revm_database::states::OriginalValuesKnown;
51// reexport traits to avoid breaking changes
52pub use reth_static_file_types as static_file;
53pub use reth_storage_api::{
54    BalNotification, BalNotificationStream, BalProvider, BalStore, BalStoreHandle,
55    GetBlockAccessListLimit, HistoryWriter, MetadataProvider, MetadataWriter, NoopBalStore,
56    SealedBal, StateWriteConfig, StatsReader, StorageSettings, StorageSettingsCache,
57};
58/// Re-export provider error.
59pub use reth_storage_errors::provider::{ProviderError, ProviderResult};
60pub use static_file::StaticFileSegment;
61
62/// Converts a [`RangeBounds`](std::ops::RangeBounds) into a concrete [`Range`](std::ops::Range)
63pub fn to_range<R: std::ops::RangeBounds<u64>>(bounds: R) -> std::ops::Range<u64> {
64    let start = match bounds.start_bound() {
65        std::ops::Bound::Included(&v) => v,
66        std::ops::Bound::Excluded(&v) => v + 1,
67        std::ops::Bound::Unbounded => 0,
68    };
69
70    let end = match bounds.end_bound() {
71        std::ops::Bound::Included(&v) => v + 1,
72        std::ops::Bound::Excluded(&v) => v,
73        std::ops::Bound::Unbounded => u64::MAX,
74    };
75
76    start..end
77}