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
75impl Default for DhtConfig {
76 fn default() -> Self {
77 Self {
78 max_k: 6,
79 max_peer_info_ttl: Duration::from_secs(3600),
80 max_stored_value_ttl: Duration::from_secs(3600),
81 max_storage_capacity: ByteSize::mib(16),
82 storage_item_time_to_idle: None,
83 local_info_refresh_period: Duration::from_secs(60),
84 local_info_announce_period: Duration::from_secs(600),
85 local_info_announce_period_max_jitter: Duration::from_secs(60),
86 routing_table_refresh_period: Duration::from_secs(600),
87 routing_table_refresh_period_max_jitter: Duration::from_secs(60),
88 announced_peers_channel_capacity: 10,
89 }
90 }
91}