Skip to main content

saorsa_node/storage/
mod.rs

1//! Storage subsystem for chunk persistence.
2//!
3//! This module provides content-addressed disk 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() = "saorsa/ant/chunk/v1"                  │
14//! │                                                         │
15//! │  handle(peer_id, data) ──▶ decode AntProtocolMessage │
16//! │                                   │                     │
17//! │         ┌─────────────────────────┼─────────────────┐  │
18//! │         ▼                         ▼                 ▼  │
19//! │   QuoteRequest           ChunkPutRequest    ChunkGetRequest
20//! │         │                         │                 │  │
21//! │         ▼                         ▼                 ▼  │
22//! │   QuoteGenerator          PaymentVerifier    DiskStorage│
23//! │         │                         │                 │  │
24//! │         └─────────────────────────┴─────────────────┘  │
25//! │                           │                             │
26//! │                 return Ok(Some(response_bytes))         │
27//! └─────────────────────────────────────────────────────────┘
28//! ```
29//!
30//! # Example
31//!
32//! ```rust,ignore
33//! use saorsa_node::storage::{AntProtocol, DiskStorage, DiskStorageConfig};
34//!
35//! // Create storage
36//! let config = DiskStorageConfig::default();
37//! let storage = DiskStorage::new(config).await?;
38//!
39//! // Create protocol handler
40//! let protocol = AntProtocol::new(storage, payment_verifier, quote_generator);
41//!
42//! // Register with saorsa-core
43//! listener.register_protocol(protocol).await?;
44//! ```
45
46mod disk;
47mod handler;
48
49pub use crate::ant_protocol::XorName;
50pub use disk::{DiskStorage, DiskStorageConfig, StorageStats};
51pub use handler::AntProtocol;