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;
50pub mod config;
51pub mod devnet;
52pub mod error;
53pub mod event;
54pub mod logging;
55pub mod node;
56pub mod payment;
57pub mod pointer;
58pub mod replication;
59pub mod storage;
60pub mod upgrade;
61#[cfg(feature = "webrtc-direct")]
62mod web_rtc;
63
64pub use ant_protocol::{
65    ChunkGetRequest, ChunkGetResponse, ChunkMessage, ChunkMessageBody, ChunkPutRequest,
66    ChunkPutResponse, ChunkQuoteRequest, ChunkQuoteResponse, CHUNK_PROTOCOL_ID,
67    CLOSE_GROUP_MAJORITY, CLOSE_GROUP_SIZE, MAX_CHUNK_SIZE,
68};
69pub use browser::{
70    BrowserBootstrapNode, BrowserChunkInfo, BrowserDevnetManifest, BrowserEndpoint,
71    BrowserPaymentNetwork, BrowserPublicFile, WebRtcDirectEndpoint, BROWSER_MANIFEST_VERSION,
72};
73pub use client::{
74    compute_address, hex_node_id_to_encoded_peer_id, peer_id_to_xor_name, xor_distance, DataChunk,
75    XorName,
76};
77pub use config::{NodeConfig, StorageConfig, WebRtcDirectConfig};
78pub use devnet::{Devnet, DevnetConfig, DevnetEvmInfo, DevnetManifest};
79pub use error::{Error, Result};
80pub use event::{NodeEvent, NodeEventsChannel};
81pub use node::{NodeBuilder, RunningNode};
82pub use payment::{PaymentStatus, PaymentVerifier, PaymentVerifierConfig};
83pub use pointer::{
84    Pointer, PointerState, PointerStore, PointerTarget, PointerTargetKind, PutOutcome,
85};
86pub use replication::{config::ReplicationConfig, ReplicationEngine};
87pub use storage::{AntProtocol, ChunkStore, ChunkStoreConfig, LmdbStorage, LmdbStorageConfig};
88
89/// Re-exports from `saorsa-core` so downstream crates (e.g. `ant-client`)
90/// can depend on `ant-node` alone without a direct `saorsa-core` dependency.
91pub mod core {
92    pub use saorsa_core::identity::{NodeIdentity, PeerId};
93    pub use saorsa_core::{
94        IPDiversityConfig, MlDsa65, MultiAddr, NodeConfig as CoreNodeConfig, NodeMode, P2PEvent,
95        P2PNode, WebRtcCertificateHash, WebRtcDirectAddr,
96    };
97}