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, doc_auto_cfg))]
14
15/// Various provider traits.
16mod traits;
17pub use traits::*;
18
19/// Provider trait implementations.
20pub mod providers;
21pub use providers::{
22    DatabaseProvider, DatabaseProviderRO, DatabaseProviderRW, HistoricalStateProvider,
23    HistoricalStateProviderRef, LatestStateProvider, LatestStateProviderRef, ProviderFactory,
24    StaticFileAccess, StaticFileWriter,
25};
26
27#[cfg(any(test, feature = "test-utils"))]
28/// Common test helpers for mocking the Provider.
29pub mod test_utils;
30/// Re-export provider error.
31pub use reth_storage_errors::provider::{ProviderError, ProviderResult};
32
33pub use reth_static_file_types as static_file;
34pub use static_file::StaticFileSegment;
35
36pub use reth_execution_types::*;
37
38pub mod bundle_state;
39
40/// Re-export `OriginalValuesKnown`
41pub use revm_database::states::OriginalValuesKnown;
42
43/// Writer standalone type.
44pub mod writer;
45
46pub use reth_chain_state::{
47    CanonStateNotification, CanonStateNotificationSender, CanonStateNotificationStream,
48    CanonStateNotifications, CanonStateSubscriptions,
49};
50
51// reexport traits to avoid breaking changes
52pub use reth_storage_api::{HistoryWriter, StatsReader};
53
54pub(crate) fn to_range<R: std::ops::RangeBounds<u64>>(bounds: R) -> std::ops::Range<u64> {
55    let start = match bounds.start_bound() {
56        std::ops::Bound::Included(&v) => v,
57        std::ops::Bound::Excluded(&v) => v + 1,
58        std::ops::Bound::Unbounded => 0,
59    };
60
61    let end = match bounds.end_bound() {
62        std::ops::Bound::Included(&v) => v + 1,
63        std::ops::Bound::Excluded(&v) => v,
64        std::ops::Bound::Unbounded => u64::MAX,
65    };
66
67    start..end
68}