Skip to main content

signet_cold_sql/
lib.rs

1//! SQL backend for cold storage.
2//!
3//! This crate provides SQL-based implementations of the [`ColdStorage`] trait
4//! for storing historical blockchain data in relational databases. All data is
5//! stored in fully decomposed SQL columns for rich queryability.
6//!
7//! # Supported Databases
8//!
9//! - **PostgreSQL** (feature `postgres`): Production-ready backend using
10//!   connection pooling.
11//! - **SQLite** (feature `sqlite`): Lightweight backend for testing and
12//!   single-binary deployments.
13//!
14//! # Feature Flags
15//!
16//! - **`postgres`**: Enables the PostgreSQL backend.
17//! - **`sqlite`**: Enables the SQLite backend.
18//! - **`test-utils`**: Enables both backends and propagates
19//!   `signet-cold/test-utils` for conformance testing.
20//!
21//! [`ColdStorage`]: signet_cold::ColdStorage
22
23#![warn(
24    missing_copy_implementations,
25    missing_debug_implementations,
26    missing_docs,
27    unreachable_pub,
28    clippy::missing_const_for_fn,
29    rustdoc::all
30)]
31#![cfg_attr(not(test), warn(unused_crate_dependencies))]
32#![deny(unused_must_use, rust_2018_idioms)]
33#![cfg_attr(docsrs, feature(doc_cfg))]
34
35// Trait impls for sqlx integration (Address, B256, Bytes, FixedBytes).
36use alloy_primitives as _;
37mod error;
38pub use error::SqlColdError;
39
40#[cfg(any(feature = "sqlite", feature = "postgres"))]
41mod columns;
42#[cfg(any(feature = "sqlite", feature = "postgres"))]
43mod convert;
44
45#[cfg(any(feature = "sqlite", feature = "postgres"))]
46mod backend;
47#[cfg(any(feature = "sqlite", feature = "postgres"))]
48pub use backend::SqlColdBackend;
49
50/// Backward-compatible alias for [`SqlColdBackend`] when using SQLite.
51#[cfg(feature = "sqlite")]
52pub type SqliteColdBackend = SqlColdBackend;
53
54/// Backward-compatible alias for [`SqlColdBackend`] when using PostgreSQL.
55#[cfg(feature = "postgres")]
56pub type PostgresColdBackend = SqlColdBackend;