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