ant_node/storage/mod.rs
1//! Storage subsystem for chunk persistence.
2//!
3//! This module provides content-addressed LMDB storage for chunks,
4//! along with a protocol handler that integrates with saorsa-core's
5//! `Protocol` trait for automatic message routing.
6//!
7//! # Architecture
8//!
9//! ```text
10//! ┌─────────────────────────────────────────────────────────┐
11//! │ AntProtocol (implements Protocol trait) │
12//! ├─────────────────────────────────────────────────────────┤
13//! │ protocol_id() = "autonomi/ant/chunk/v1" │
14//! │ │
15//! │ handle(peer_id, data) ──▶ decode AntProtocolMessage │
16//! │ │ │
17//! │ ┌─────────────────────────┼─────────────────┐ │
18//! │ ▼ ▼ ▼ │
19//! │ QuoteRequest ChunkPutRequest ChunkGetRequest
20//! │ │ │ │ │
21//! │ ▼ ▼ ▼ │
22//! │ QuoteGenerator PaymentVerifier LmdbStorage│
23//! │ │ │ │ │
24//! │ └─────────────────────────┴─────────────────┘ │
25//! │ │ │
26//! │ return Ok(Some(response_bytes)) │
27//! └─────────────────────────────────────────────────────────┘
28//! ```
29//!
30//! # Example
31//!
32//! ```rust,ignore
33//! use std::sync::Arc;
34//! use ant_node::storage::{AntProtocol, LmdbStorage, LmdbStorageConfig};
35//!
36//! // Create storage
37//! let config = LmdbStorageConfig::default();
38//! let storage = Arc::new(LmdbStorage::new(config).await?);
39//!
40//! // Create protocol handler
41//! let protocol = AntProtocol::new(storage, Arc::new(payment_verifier), Arc::new(quote_generator));
42//!
43//! // Register with saorsa-core
44//! listener.register_protocol(protocol).await?;
45//! ```
46
47mod handler;
48mod lmdb;
49
50pub use crate::ant_protocol::XorName;
51pub use handler::AntProtocol;
52pub use lmdb::{LmdbStorage, LmdbStorageConfig, StorageStats};