Skip to main content

saorsa_node/ant_protocol/
mod.rs

1//! ANT protocol implementation for the saorsa network.
2//!
3//! This module implements the wire protocol for storing and retrieving
4//! data on the saorsa network, compatible with the autonomi network protocol.
5//!
6//! # Data Types
7//!
8//! The ANT protocol supports multiple data types:
9//!
10//! - **Chunk**: Immutable, content-addressed data (hash == address)
11//! - *Scratchpad*: Mutable, owner-indexed data (planned)
12//! - *Pointer*: Lightweight mutable references (planned)
13//! - *`GraphEntry`*: DAG entries with parent links (planned)
14//!
15//! # Protocol Overview
16//!
17//! The protocol uses bincode serialization for compact, fast encoding.
18//! Each data type has its own message types for PUT/GET operations.
19//!
20//! ## Chunk Messages
21//!
22//! - `ChunkPutRequest` / `ChunkPutResponse` - Store chunks
23//! - `ChunkGetRequest` / `ChunkGetResponse` - Retrieve chunks
24//! - `ChunkQuoteRequest` / `ChunkQuoteResponse` - Request storage quotes
25//!
26//! ## Payment Flow
27//!
28//! 1. Client requests a quote via `ChunkQuoteRequest`
29//! 2. Node returns signed `PaymentQuote` in `ChunkQuoteResponse`
30//! 3. Client pays on Arbitrum via `PaymentVault.payForQuotes()`
31//! 4. Client sends `ChunkPutRequest` with `payment_proof`
32//! 5. Node verifies payment and stores chunk
33//!
34//! # Example
35//!
36//! ```rust,ignore
37//! use saorsa_node::ant_protocol::{ChunkMessage, ChunkPutRequest, ChunkGetRequest};
38//!
39//! // Create a PUT request
40//! let address = compute_address(&data);
41//! let request = ChunkPutRequest::with_payment(address, data, payment_proof);
42//! let message = ChunkMessage::PutRequest(request);
43//! let bytes = message.encode()?;
44//!
45//! // Decode a response
46//! let response = ChunkMessage::decode(&response_bytes)?;
47//! ```
48
49pub mod chunk;
50
51// Re-export chunk types for convenience
52pub use chunk::{
53    ChunkGetRequest, ChunkGetResponse, ChunkMessage, ChunkMessageBody, ChunkPutRequest,
54    ChunkPutResponse, ChunkQuoteRequest, ChunkQuoteResponse, ProtocolError, XorName,
55    CHUNK_PROTOCOL_ID, DATA_TYPE_CHUNK, MAX_CHUNK_SIZE, PROTOCOL_VERSION,
56};