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/// 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, StaticFileProviderBuilder, StaticFileWriter,
25};
26
27pub mod changesets_utils;
28
29#[cfg(any(test, feature = "test-utils"))]
30/// Common test helpers for mocking the Provider.
31pub mod test_utils;
32
33pub mod either_writer;
34pub use either_writer::*;
35
36pub use reth_chain_state::{
37    CanonStateNotification, CanonStateNotificationSender, CanonStateNotificationStream,
38    CanonStateNotifications, CanonStateSubscriptions,
39};
40pub use reth_execution_types::*;
41/// Re-export `OriginalValuesKnown`
42pub use revm_database::states::OriginalValuesKnown;
43// reexport traits to avoid breaking changes
44pub use reth_static_file_types as static_file;
45pub use reth_storage_api::{
46    HistoryWriter, MetadataProvider, MetadataWriter, StatsReader, StorageSettings,
47    StorageSettingsCache,
48};
49/// Re-export provider error.
50pub use reth_storage_errors::provider::{ProviderError, ProviderResult};
51pub use static_file::StaticFileSegment;
52
53pub(crate) fn to_range<R: std::ops::RangeBounds<u64>>(bounds: R) -> std::ops::Range<u64> {
54    let start = match bounds.start_bound() {
55        std::ops::Bound::Included(&v) => v,
56        std::ops::Bound::Excluded(&v) => v + 1,
57        std::ops::Bound::Unbounded => 0,
58    };
59
60    let end = match bounds.end_bound() {
61        std::ops::Bound::Included(&v) => v + 1,
62        std::ops::Bound::Excluded(&v) => v,
63        std::ops::Bound::Unbounded => u64::MAX,
64    };
65
66    start..end
67}