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
41pub use reth_chain_state::{
42    CanonStateNotification, CanonStateNotificationSender, CanonStateNotificationStream,
43    CanonStateNotifications, CanonStateSubscriptions,
44};
45pub use reth_execution_types::*;
46/// Re-export `OriginalValuesKnown`
47pub use revm_database::states::OriginalValuesKnown;
48// reexport traits to avoid breaking changes
49pub use reth_static_file_types as static_file;
50pub use reth_storage_api::{
51    HistoryWriter, MetadataProvider, MetadataWriter, StateWriteConfig, StatsReader,
52    StorageSettings, StorageSettingsCache,
53};
54/// Re-export provider error.
55pub use reth_storage_errors::provider::{ProviderError, ProviderResult};
56pub use static_file::StaticFileSegment;
57
58/// Converts a [`RangeBounds`](std::ops::RangeBounds) into a concrete [`Range`](std::ops::Range)
59pub fn to_range<R: std::ops::RangeBounds<u64>>(bounds: R) -> std::ops::Range<u64> {
60    let start = match bounds.start_bound() {
61        std::ops::Bound::Included(&v) => v,
62        std::ops::Bound::Excluded(&v) => v + 1,
63        std::ops::Bound::Unbounded => 0,
64    };
65
66    let end = match bounds.end_bound() {
67        std::ops::Bound::Included(&v) => v + 1,
68        std::ops::Bound::Excluded(&v) => v,
69        std::ops::Bound::Unbounded => u64::MAX,
70    };
71
72    start..end
73}