1pub mod capacity_signaling;
10pub mod core_engine;
11pub mod telemetry;
12pub mod trust_weighted_dht;
13pub mod trust_weighted_kademlia;
14
15pub use trust_weighted_dht::{
17 Contact, Dht, Key, Outcome, PutPolicy, PutReceipt, eigen_trust_epoch, record_interaction,
18};
19
20pub use trust_weighted_dht::PeerId;
22
23pub use trust_weighted_kademlia::TrustWeightedKademlia;
25
26pub use capacity_signaling::{CapacityGossip, CapacityHistogram, CapacityManager, CapacityStats};
28
29pub use telemetry::{DhtTelemetry, OperationStats, OperationType, TelemetryStats};
31
32pub use core_engine::{DhtCoreEngine, DhtKey, NodeCapacity, NodeId as DhtNodeId, NodeInfo};
34
35pub type DHT = DhtCoreEngine;
37pub type DHTNode = NodeInfo;
38pub type SerializableDHTNode = NodeInfo;
39
40pub use trust_weighted_dht::Key as DHT_Key;
42
43use serde::{Deserialize, Serialize};
45use std::time::Duration;
46
47#[derive(Debug, Clone, Serialize, Deserialize)]
49pub struct DHTConfig {
50 pub replication_factor: usize,
52 pub bucket_size: usize,
54 pub alpha: usize,
56 pub record_ttl: Duration,
58 pub bucket_refresh_interval: Duration,
60 pub republish_interval: Duration,
62 pub max_distance: u8,
64}
65
66impl Default for DHTConfig {
67 fn default() -> Self {
68 Self {
69 replication_factor: 8,
70 bucket_size: 20,
71 alpha: 3,
72 record_ttl: Duration::from_secs(3600),
73 bucket_refresh_interval: Duration::from_secs(3600),
74 republish_interval: Duration::from_secs(3600),
75 max_distance: 160,
76 }
77 }
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize)]
82pub struct Record {
83 pub key: Key,
85 pub value: Vec<u8>,
87 pub publisher: PeerId,
89 pub created_at: std::time::SystemTime,
91 pub expires_at: std::time::SystemTime,
93 pub signature: Option<Vec<u8>>,
95}
96
97impl Record {
98 pub fn new(key: Key, value: Vec<u8>, publisher: PeerId) -> Self {
100 let now = std::time::SystemTime::now();
101 Self {
102 key,
103 value,
104 publisher,
105 created_at: now,
106 expires_at: now + std::time::Duration::from_secs(3600), signature: None,
108 }
109 }
110
111 pub fn is_expired(&self) -> bool {
113 std::time::SystemTime::now() > self.expires_at
114 }
115}
116
117pub mod client;
119pub mod content_addressing;
120pub mod enhanced_storage;
121pub mod geographic_network_integration;
122pub mod geographic_routing;
123pub mod geographic_routing_table;
124pub mod latency_aware_selection;
125pub mod network_integration;
126pub mod optimized_storage;
127pub mod reed_solomon;
128pub mod rsps_integration;
129pub mod skademlia;
130pub mod witness;