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 discovering public overlay peers.
39    ///
40    /// Default: 3 minutes.
41    #[serde(with = "serde_helpers::humantime")]
42    pub public_overlay_peer_discovery_period: Duration,
43
44    /// A maximum value of a random jitter for the peer discovery period.
45    ///
46    /// Default: 30 seconds.
47    #[serde(with = "serde_helpers::humantime")]
48    pub public_overlay_peer_discovery_max_jitter: Duration,
49
50    /// Number of peers to send during entries exchange request.
51    ///
52    /// Default: 20.
53    pub exchange_public_entries_batch: usize,
54}
55
56impl Default for OverlayConfig {
57    fn default() -> Self {
58        Self {
59            public_overlay_peer_store_period: Duration::from_secs(3 * 60),
60            public_overlay_peer_store_max_jitter: Duration::from_secs(30),
61            public_overlay_peer_store_max_entries: 20,
62            public_overlay_peer_exchange_period: Duration::from_secs(3 * 60),
63            public_overlay_peer_exchange_max_jitter: Duration::from_secs(30),
64            public_overlay_peer_discovery_period: Duration::from_secs(3 * 60),
65            public_overlay_peer_discovery_max_jitter: Duration::from_secs(30),
66            exchange_public_entries_batch: 20,
67        }
68    }
69}