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

As of 0.11, the shared protocol types and helpers live in the ant_protocol crate. This module re-exports them so existing callers of ant_node::client::* continue to compile; new code should prefer ant_protocol::* directly.

§Example

use ant_client::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::connect(&bootstrap_peers, Default::default()).await?;
    let address = client.chunk_put(bytes::Bytes::from("hello world")).await?;
    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
Content-addressed identifier (32 bytes).