Expand description
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 chunksChunkGetRequest/ChunkGetResponse- Retrieve chunksChunkQuoteRequest/ChunkQuoteResponse- Request storage quotes
§Payment Flow
- Client requests a quote via
ChunkQuoteRequest - Node returns signed
PaymentQuoteinChunkQuoteResponse - Client pays on Arbitrum via
PaymentVault.payForQuotes() - Client sends
ChunkPutRequestwithpayment_proof - Node verifies payment and stores chunk
§Example
ⓘ
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)?;Re-exports§
pub use chunk::ChunkGetRequest;pub use chunk::ChunkGetResponse;pub use chunk::ChunkMessage;pub use chunk::ChunkMessageBody;pub use chunk::ChunkPutRequest;pub use chunk::ChunkPutResponse;pub use chunk::ChunkQuoteRequest;pub use chunk::ChunkQuoteResponse;pub use chunk::MerkleCandidateQuoteRequest;pub use chunk::MerkleCandidateQuoteResponse;pub use chunk::ProtocolError;pub use chunk::XorName;pub use chunk::CHUNK_PROTOCOL_ID;pub use chunk::DATA_TYPE_CHUNK;pub use chunk::MAX_CHUNK_SIZE;pub use chunk::MAX_WIRE_MESSAGE_SIZE;pub use chunk::PROOF_TAG_MERKLE;pub use chunk::PROOF_TAG_SINGLE_NODE;pub use chunk::PROTOCOL_VERSION;
Modules§
- chunk
- Chunk message types for the ANT protocol.
Constants§
- CLOSE_
GROUP_ MAJORITY - Minimum number of close group members that must agree for a decision to be valid.
- CLOSE_
GROUP_ SIZE - Number of nodes in a Kademlia close group.