Skip to main content

ant_node/
lib.rs

1//! # ant-node
2//!
3//! A pure quantum-proof network node for the Autonomi decentralized network.
4//!
5//! This crate provides a thin wrapper around `saorsa-core` that adds:
6//! - Auto-upgrade system with ML-DSA signature verification
7//! - CLI interface and configuration
8//! - Content-addressed chunk storage with EVM payment
9//!
10//! ## Architecture
11//!
12//! `ant-node` delegates all core functionality to `saorsa-core`:
13//! - Networking via `P2PNode`
14//! - DHT via `AdaptiveDHT`
15//! - Trust via `TrustEngine`
16//! - Security via `IPDiversityConfig`
17//!
18//! ## Data Types
19//!
20//! Two data types:
21//! - **Chunk**: Immutable content-addressed data (hash(value) == key)
22//! - **Pointer**: A paid mutable reference signed by an immutable owner, stored
23//!   at an address derived from the owner key (see [`mod@pointer`] and ADR-0016)
24//!
25//! ## Example
26//!
27//! ```rust,no_run
28//! use ant_node::{NodeBuilder, NodeConfig};
29//!
30//! #[tokio::main]
31//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
32//!     let config = NodeConfig::default();
33//!     let mut node = NodeBuilder::new(config).build().await?;
34//!     node.run().await?;
35//!     Ok(())
36//! }
37//! ```
38
39#![deny(unsafe_code)]
40#![warn(missing_docs)]
41#![warn(clippy::all)]
42#![warn(clippy::pedantic)]
43// When the `logging` feature is off, variables used only in log macros become
44// unused. These are expected and harmless — the compiler optimises them away.
45#![cfg_attr(not(feature = "logging"), allow(unused_variables, unused_assignments))]
46
47pub mod ant_protocol;
48pub mod browser;
49pub mod client;
50mod codec;
51pub mod config;
52pub mod devnet;
53pub mod error;
54pub mod event;
55pub mod logging;
56pub mod node;
57pub mod payment;
58pub mod pointer;
59pub mod replication;
60pub mod storage;
61pub mod upgrade;
62#[cfg(feature = "webrtc-direct")]
63mod web_rtc;
64
65pub use ant_protocol::{
66    ChunkGetRequest, ChunkGetResponse, ChunkMessage, ChunkMessageBody, ChunkPutRequest,
67    ChunkPutResponse, ChunkQuoteRequest, ChunkQuoteResponse, CHUNK_PROTOCOL_ID,
68    CLOSE_GROUP_MAJORITY, CLOSE_GROUP_SIZE, MAX_CHUNK_SIZE,
69};
70pub use browser::{
71    BrowserBootstrapNode, BrowserChunkInfo, BrowserDevnetManifest, BrowserEndpoint,
72    BrowserPaymentNetwork, BrowserPublicFile, WebRtcDirectEndpoint, BROWSER_MANIFEST_VERSION,
73};
74pub use client::{
75    compute_address, hex_node_id_to_encoded_peer_id, peer_id_to_xor_name, xor_distance, DataChunk,
76    XorName,
77};
78pub use config::{NodeConfig, StorageConfig, WebRtcDirectConfig};
79pub use devnet::{Devnet, DevnetConfig, DevnetEvmInfo, DevnetManifest};
80pub use error::{Error, Result};
81pub use event::{NodeEvent, NodeEventsChannel};
82pub use node::{NodeBuilder, RunningNode};
83pub use payment::{PaymentStatus, PaymentVerifier, PaymentVerifierConfig};
84pub use pointer::{
85    Pointer, PointerState, PointerStore, PointerTarget, PointerTargetKind, PutOutcome,
86};
87pub use replication::{config::ReplicationConfig, ReplicationEngine};
88pub use storage::{AntProtocol, ChunkStore, ChunkStoreConfig};
89
90/// Re-exports from `saorsa-core` so downstream crates (e.g. `ant-client`)
91/// can depend on `ant-node` alone without a direct `saorsa-core` dependency.
92pub mod core {
93    pub use saorsa_core::identity::{NodeIdentity, PeerId};
94    pub use saorsa_core::{
95        IPDiversityConfig, MlDsa65, MultiAddr, NodeConfig as CoreNodeConfig, NodeMode, P2PEvent,
96        P2PNode, WebRtcCertificateHash, WebRtcDirectAddr,
97    };
98}