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
//! ANT protocol implementation for the Autonomi network.
//!
//! This module implements the wire protocol for storing and retrieving
//! data on the Autonomi network.
//!
//! # Data Types
//!
//! The ANT protocol supports a single data type:
//!
//! - **Chunk**: Immutable, content-addressed data (hash == address)
//!
//! # Protocol Overview
//!
//! The protocol uses postcard serialization for compact, fast encoding.
//! Each data type has its own message types for PUT/GET operations.
//!
//! ## Chunk Messages
//!
//! - `ChunkPutRequest` / `ChunkPutResponse` - Store chunks
//! - `ChunkGetRequest` / `ChunkGetResponse` - Retrieve chunks
//! - `ChunkQuoteRequest` / `ChunkQuoteResponse` - Request storage quotes
//!
//! ## Payment Flow
//!
//! 1. Client requests a quote via `ChunkQuoteRequest`
//! 2. Node returns signed `PaymentQuote` in `ChunkQuoteResponse`
//! 3. Client pays on Arbitrum via `PaymentVault.payForQuotes()`
//! 4. Client sends `ChunkPutRequest` with `payment_proof`
//! 5. Node verifies payment and stores chunk
//!
//! # Example
//!
//! ```rust,ignore
//! use ant_node::ant_protocol::{ChunkMessage, ChunkPutRequest, ChunkGetRequest};
//!
//! // Create a PUT request
//! let address = compute_address(&data);
//! let request = ChunkPutRequest::with_payment(address, data, payment_proof);
//! let message = ChunkMessage::PutRequest(request);
//! let bytes = message.encode()?;
//!
//! // Decode a response
//! let response = ChunkMessage::decode(&response_bytes)?;
//! ```
/// Number of nodes in a Kademlia close group.
///
/// Clients fetch quotes from the `CLOSE_GROUP_SIZE` closest nodes to a target
/// address and select the median-priced quote for payment.
pub const CLOSE_GROUP_SIZE: usize = 7;
/// Minimum number of close group members that must agree for a decision to be valid.
///
/// This is a simple majority: `(CLOSE_GROUP_SIZE / 2) + 1`.
pub const CLOSE_GROUP_MAJORITY: usize = + 1;
// Re-export chunk types for convenience
pub use ;