1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//! Storage subsystem for chunk persistence.
//!
//! This module provides content-addressed LMDB storage for chunks,
//! along with a protocol handler that integrates with saorsa-core's
//! `Protocol` trait for automatic message routing.
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────┐
//! │ AntProtocol (implements Protocol trait) │
//! ├─────────────────────────────────────────────────────────┤
//! │ protocol_id() = "autonomi.ant.chunk.v1" │
//! │ │
//! │ handle(peer_id, data) ──▶ decode AntProtocolMessage │
//! │ │ │
//! │ ┌─────────────────────────┼─────────────────┐ │
//! │ ▼ ▼ ▼ │
//! │ QuoteRequest ChunkPutRequest ChunkGetRequest
//! │ │ │ │ │
//! │ ▼ ▼ ▼ │
//! │ QuoteGenerator PaymentVerifier LmdbStorage│
//! │ │ │ │ │
//! │ └─────────────────────────┴─────────────────┘ │
//! │ │ │
//! │ return Ok(Some(response_bytes)) │
//! └─────────────────────────────────────────────────────────┘
//! ```
//!
//! # Example
//!
//! ```rust,ignore
//! use std::sync::Arc;
//! use ant_node::storage::{AntProtocol, LmdbStorage, LmdbStorageConfig};
//!
//! // Create storage
//! let config = LmdbStorageConfig::default();
//! let storage = Arc::new(LmdbStorage::new(config).await?);
//!
//! // Create protocol handler
//! let protocol = AntProtocol::new(storage, Arc::new(payment_verifier), Arc::new(quote_generator));
//!
//! // Register with saorsa-core
//! listener.register_protocol(protocol).await?;
//! ```
pub
pub
pub
pub
pub
pub use crateXorName;
pub use ;
pub use ;
pub use ;
pub use AntProtocol;
pub use ChunkRequestContext;
pub use SELF_CLOSENESS_GATE_WIDTH;
pub use CapacityVerdict;
pub use ;
pub use ;
/// Bytes in one MiB.
pub const MIB: u64 = 1024 * 1024;
/// Bytes in one GiB.
pub const GIB: u64 = 1024 * MIB;
/// Default free disk space to keep unused on the storage partition.
pub const DEFAULT_DISK_RESERVE: u64 = 500 * MIB;
/// Statistics about storage operations.
///
/// Counters other than `current_chunks` are cumulative for the lifetime of the
/// process; `current_chunks` is the live count.