irontide_dht/lib.rs
1#![warn(missing_docs)]
2//! Kademlia DHT implementation: BEP 5 routing, BEP 42 security, BEP 44 storage, BEP 51 indexing.
3//!
4//! Implements the Mainline DHT protocol: KRPC message encoding, Kademlia
5//! routing table, peer discovery, and announce operations.
6//!
7//! # Architecture
8//!
9//! The DHT runs as an actor: `DhtHandle::start()` spawns a background task
10//! that owns all state (routing table, UDP socket, pending queries). The
11//! returned `DhtHandle` is a cheap, cloneable sender for submitting commands.
12
13mod actor;
14/// BEP 44 immutable and mutable item storage.
15pub mod bep44;
16/// BEP 33 bloom filters for DHT scrape swarm estimation.
17pub mod bloom;
18/// Compact node encoding (26-byte IPv4, 38-byte IPv6).
19pub mod compact;
20/// Self-contained parallel DHT lookup with 256-node tracking.
21pub(crate) mod dht_lookup;
22/// DHT error types.
23pub mod error;
24/// Broadcast surface for runtime DhtHandle replacement (M173 Lane B B5).
25pub mod handle;
26/// KRPC message encoding and decoding (BEP 5).
27pub mod krpc;
28/// Generic iterative Kademlia lookup (shared by bootstrap find_node).
29pub(crate) mod lookup;
30/// BEP 42 node ID generation and validation.
31pub mod node_id;
32/// Per-info_hash peer storage and announce token management.
33pub mod peer_store;
34/// Kademlia routing table with k-buckets.
35pub mod routing_table;
36/// DHT item storage backend.
37pub mod storage;
38
39pub use actor::{DhtConfig, DhtHandle, DhtStats, SampleInfohashesResult};
40pub use bep44::{
41 ImmutableItem, MAX_SALT_SIZE, MAX_VALUE_SIZE, MutableItem, build_signing_buffer,
42 compute_mutable_target,
43};
44pub use compact::{
45 COMPACT_NODE_SIZE, COMPACT_NODE6_SIZE, CompactNodeInfo, CompactNodeInfo6, encode_compact_nodes,
46 encode_compact_nodes6, parse_compact_nodes, parse_compact_nodes6,
47};
48pub use error::{Error, Result};
49pub use handle::{DhtBroadcast, DhtReceiver};
50pub use krpc::{
51 GetPeersResponse, KrpcBody, KrpcMessage, KrpcQuery, KrpcResponse, SampleInfohashesResponse,
52 TransactionId,
53};
54pub use node_id::{
55 ExternalIpVoter, IpVoteSource, generate_node_id, is_bep42_exempt, is_valid_node_id,
56};
57pub use routing_table::{NodeStatus, RoutingTable};
58pub use storage::{DhtStorage, InMemoryDhtStorage};