tycho_network/dht/
config.rs1use std::time::Duration;
2
3use bytesize::ByteSize;
4use serde::{Deserialize, Serialize};
5use tycho_util::serde_helpers;
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
9#[serde(default)]
10pub struct DhtConfig {
11 pub max_k: usize,
15
16 #[serde(with = "serde_helpers::humantime")]
20 pub max_peer_info_ttl: Duration,
21
22 #[serde(with = "serde_helpers::humantime")]
26 pub max_stored_value_ttl: Duration,
27
28 pub max_storage_capacity: ByteSize,
32
33 #[serde(with = "serde_helpers::humantime")]
37 pub storage_item_time_to_idle: Option<Duration>,
38
39 #[serde(with = "serde_helpers::humantime")]
43 pub local_info_refresh_period: Duration,
44
45 #[serde(with = "serde_helpers::humantime")]
49 pub local_info_announce_period: Duration,
50
51 #[serde(with = "serde_helpers::humantime")]
55 pub local_info_announce_period_max_jitter: Duration,
56
57 #[serde(with = "serde_helpers::humantime")]
61 pub routing_table_refresh_period: Duration,
62
63 #[serde(with = "serde_helpers::humantime")]
67 pub routing_table_refresh_period_max_jitter: Duration,
68
69 pub announced_peers_channel_capacity: usize,
73
74 #[serde(with = "serde_helpers::humantime")]
78 pub bootstrap_peers_refill_period: Option<Duration>,
79
80 #[serde(with = "serde_helpers::humantime")]
84 pub request_timeout: Duration,
85}
86
87impl Default for DhtConfig {
88 fn default() -> Self {
89 Self {
90 max_k: 6,
91 max_peer_info_ttl: Duration::from_secs(3600),
92 max_stored_value_ttl: Duration::from_secs(3600),
93 max_storage_capacity: ByteSize::mib(16),
94 storage_item_time_to_idle: None,
95 local_info_refresh_period: Duration::from_secs(60),
96 local_info_announce_period: Duration::from_secs(600),
97 local_info_announce_period_max_jitter: Duration::from_secs(60),
98 routing_table_refresh_period: Duration::from_secs(600),
99 routing_table_refresh_period_max_jitter: Duration::from_secs(60),
100 announced_peers_channel_capacity: 10,
101 bootstrap_peers_refill_period: Some(Duration::from_secs(60)),
102 request_timeout: Duration::from_millis(500),
103 }
104 }
105}