Expand description
Storage subsystem for chunk persistence.
This module provides content-addressed storage for chunks, one immutable file per
chunk, along with a protocol handler that integrates with saorsa-core’s Protocol
trait for automatic message routing.
§Architecture
┌─────────────────────────────────────────────────────────┐
│ AntProtocol (implements Protocol trait) │
├─────────────────────────────────────────────────────────┤
│ protocol_id() = "autonomi.ant.chunk.v1" │
│ │
│ handle(peer_id, data) ──▶ decode AntProtocolMessage │
│ │ │
│ ┌─────────────────────────┼─────────────────┐ │
│ ▼ ▼ ▼ │
│ QuoteRequest ChunkPutRequest ChunkGetRequest
│ │ │ │ │
│ ▼ ▼ ▼ │
│ QuoteGenerator PaymentVerifier ChunkStore│
│ │ │ │ │
│ └─────────────────────────┴─────────────────┘ │
│ │ │
│ return Ok(Some(response_bytes)) │
└─────────────────────────────────────────────────────────┘§Example
ⓘ
use std::sync::Arc;
use ant_node::storage::{AntProtocol, ChunkStore, ChunkStoreConfig};
// Create storage
let config = ChunkStoreConfig::default();
let storage = Arc::new(ChunkStore::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?;Structs§
- AntProtocol
- ANT protocol handler.
- Chunk
Store - Content-addressed store holding one immutable file per chunk.
- Chunk
Store Config - Configuration for
ChunkStore. - Disk
Space - Free and total bytes on the partition holding the record store.
- Storage
Stats - Statistics about storage operations.
Constants§
- DEFAULT_
DISK_ RESERVE - Default free disk space to keep unused on the storage partition.
- GIB
- Bytes in one GiB.
- MIB
- Bytes in one MiB.
- SELF_
CLOSENESS_ GATE_ WIDTH - Width of the self-closeness gate on client PUTs (ADR-0003): a node accepts
a PUT only when it is within its own local
SELF_CLOSENESS_GATE_WIDTHclosest peers to the address.
Type Aliases§
- XorName
- Content-addressed identifier (32 bytes).