Skip to main content

Module storage

Module storage 

Source
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.
ChunkStore
Content-addressed store holding one immutable file per chunk.
ChunkStoreConfig
Configuration for ChunkStore.
StorageStats
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_WIDTH closest peers to the address.

Type Aliases§

XorName
Content-addressed identifier (32 bytes).