tycho_network/overlay/
config.rs

1use std::time::Duration;
2
3use serde::{Deserialize, Serialize};
4use tycho_util::serde_helpers;
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
7#[serde(default)]
8pub struct OverlayConfig {
9    /// A period of storing public overlay entries in local DHT.
10    ///
11    /// Default: 3 minutes.
12    #[serde(with = "serde_helpers::humantime")]
13    pub public_overlay_peer_store_period: Duration,
14
15    /// A maximum value of a random jitter for the entries store period.
16    ///
17    /// Default: 30 seconds.
18    #[serde(with = "serde_helpers::humantime")]
19    pub public_overlay_peer_store_max_jitter: Duration,
20
21    /// A maximum number of public overlay entries to store.
22    ///
23    /// Default: 20.
24    pub public_overlay_peer_store_max_entries: usize,
25
26    /// A period of exchanging public overlay peers.
27    ///
28    /// Default: 3 minutes.
29    #[serde(with = "serde_helpers::humantime")]
30    pub public_overlay_peer_exchange_period: Duration,
31
32    /// A maximum value of a random jitter for the peer exchange period.
33    ///
34    /// Default: 30 seconds.
35    #[serde(with = "serde_helpers::humantime")]
36    pub public_overlay_peer_exchange_max_jitter: Duration,
37
38    /// A period of collecting public overlay entries.
39    ///
40    /// Default: 3 minutes.
41    #[serde(with = "serde_helpers::humantime")]
42    pub public_overlay_peer_collect_period: Duration,
43
44    /// A maximum value of a random jitter for the peer collect period.
45    ///
46    /// Default: 30 seconds.
47    #[serde(with = "serde_helpers::humantime")]
48    pub public_overlay_peer_collect_max_jitter: Duration,
49
50    /// A period of discovering public overlay peers.
51    ///
52    /// Default: 3 minutes.
53    #[serde(with = "serde_helpers::humantime")]
54    pub public_overlay_peer_discovery_period: Duration,
55
56    /// A maximum value of a random jitter for the peer discovery period.
57    ///
58    /// Default: 30 seconds.
59    #[serde(with = "serde_helpers::humantime")]
60    pub public_overlay_peer_discovery_max_jitter: Duration,
61
62    /// Number of peers to send during entries exchange request.
63    ///
64    /// Default: 20.
65    pub exchange_public_entries_batch: usize,
66}
67
68impl Default for OverlayConfig {
69    fn default() -> Self {
70        Self {
71            public_overlay_peer_store_period: Duration::from_secs(3 * 60),
72            public_overlay_peer_store_max_jitter: Duration::from_secs(30),
73            public_overlay_peer_store_max_entries: 20,
74            public_overlay_peer_exchange_period: Duration::from_secs(3 * 60),
75            public_overlay_peer_exchange_max_jitter: Duration::from_secs(30),
76            public_overlay_peer_collect_period: Duration::from_secs(10),
77            public_overlay_peer_collect_max_jitter: Duration::from_secs(5),
78            public_overlay_peer_discovery_period: Duration::from_secs(3 * 60),
79            public_overlay_peer_discovery_max_jitter: Duration::from_secs(30),
80            exchange_public_entries_batch: 20,
81        }
82    }
83}