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 replication_grace_period::{ReplicationGracePeriodConfig, FailedNodeInfo, NodeFailureReason, ReplicationError, EndpointRegistration};
34
35pub use node_failure_tracker::{NodeFailureTracker, DefaultNodeFailureTracker, DhtClient};
37
38pub use core_engine::{DhtCoreEngine, DhtKey, NodeCapacity, NodeId as DhtNodeId, NodeInfo};
40
41pub type DHT = DhtCoreEngine;
43pub type DHTNode = NodeInfo;
44pub type SerializableDHTNode = NodeInfo;
45
46pub use trust_weighted_dht::Key as DHT_Key;
48
49use serde::{Deserialize, Serialize};
51use std::time::Duration;
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55pub struct DHTConfig {
56 pub replication_factor: usize,
58 pub bucket_size: usize,
60 pub alpha: usize,
62 pub record_ttl: Duration,
64 pub bucket_refresh_interval: Duration,
66 pub republish_interval: Duration,
68 pub max_distance: u8,
70}
71
72impl Default for DHTConfig {
73 fn default() -> Self {
74 Self {
75 replication_factor: 8,
76 bucket_size: 20,
77 alpha: 3,
78 record_ttl: Duration::from_secs(3600),
79 bucket_refresh_interval: Duration::from_secs(3600),
80 republish_interval: Duration::from_secs(3600),
81 max_distance: 160,
82 }
83 }
84}
85
86#[derive(Debug, Clone, Serialize, Deserialize)]
88pub struct Record {
89 pub key: Key,
91 pub value: Vec<u8>,
93 pub publisher: PeerId,
95 pub created_at: std::time::SystemTime,
97 pub expires_at: std::time::SystemTime,
99 pub signature: Option<Vec<u8>>,
101}
102
103impl Record {
104 pub fn new(key: Key, value: Vec<u8>, publisher: PeerId) -> Self {
106 let now = std::time::SystemTime::now();
107 Self {
108 key,
109 value,
110 publisher,
111 created_at: now,
112 expires_at: now + std::time::Duration::from_secs(3600), signature: None,
114 }
115 }
116
117 pub fn is_expired(&self) -> bool {
119 std::time::SystemTime::now() > self.expires_at
120 }
121}
122
123pub mod client;
125pub mod content_addressing;
126pub mod enhanced_storage;
127pub mod geographic_network_integration;
128pub mod geographic_routing;
129pub mod geographic_routing_table;
130pub mod latency_aware_selection;
131pub mod network_integration;
132pub mod node_failure_tracker;
133pub mod optimized_storage;
134pub mod reed_solomon;
135pub mod replication_grace_period;
136pub mod rsps_integration;
137pub mod skademlia;
138pub mod witness;