Skip to main content

Module client

Module client 

Source
Expand description

Protocol helpers for ant-node client operations.

This module provides low-level protocol support for client-node communication. For high-level client operations, use the ant-client crate instead.

§Architecture

This module contains:

  1. Protocol message handlers: Send/await pattern for chunks
  2. Data types: Common types like XorName, DataChunk, address computation

§Migration Note

The QuantumClient has been deprecated and consolidated into ant-client::Client. Use ant-client for all client operations.

§Example

use ant_client::Client; // Use ant-client instead of QuantumClient

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // High-level client API
    let client = Client::connect(&bootstrap_peers, Default::default()).await?;

    // Store data with payment
    let address = client.chunk_put(bytes::Bytes::from("hello world")).await?;

    // Retrieve data
    let chunk = client.chunk_get(&address).await?;

    Ok(())
}

Structs§

ChunkStats
Statistics about chunk operations.
DataChunk
A chunk of data with its content-addressed identifier.

Functions§

compute_address
Compute the content address (BLAKE3 hash) for the given data.
hex_node_id_to_encoded_peer_id
Convert a hex-encoded 32-byte node ID to an EncodedPeerId.
peer_id_to_xor_name
Convert a hex-encoded peer ID string to an XorName.
send_and_await_chunk_response
Send a chunk-protocol message to target_peer and await a matching response.
xor_distance
Compute the XOR distance between two 32-byte addresses.

Type Aliases§

XorName
A content-addressed identifier (32 bytes).