reth_dns_discovery/
config.rs

1use crate::tree::LinkEntry;
2use std::{
3    collections::HashSet,
4    num::{NonZeroU32, NonZeroUsize},
5    time::Duration,
6};
7
8#[cfg(feature = "serde")]
9use serde::{Deserialize, Serialize};
10
11/// Settings for the [`DnsDiscoveryService`](crate::DnsDiscoveryService).
12#[derive(Debug, Clone)]
13#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
14pub struct DnsDiscoveryConfig {
15    /// Timeout for DNS lookups.
16    ///
17    /// Default: 5s
18    pub lookup_timeout: Duration,
19    /// The DNS request rate limit
20    ///
21    /// Default: 3
22    pub max_requests_per_sec: NonZeroUsize,
23    /// The rate at which trees should be updated.
24    ///
25    /// Default: 30min
26    pub recheck_interval: Duration,
27    /// Maximum number of cached DNS records.
28    pub dns_record_cache_limit: NonZeroU32,
29    /// Links to the DNS networks to bootstrap.
30    pub bootstrap_dns_networks: Option<HashSet<LinkEntry>>,
31}
32
33impl Default for DnsDiscoveryConfig {
34    fn default() -> Self {
35        Self {
36            lookup_timeout: Duration::from_secs(5),
37            max_requests_per_sec: NonZeroUsize::new(3).unwrap(),
38            recheck_interval: Duration::from_secs(60 * 30),
39            dns_record_cache_limit: NonZeroU32::new(1_000).unwrap(),
40            bootstrap_dns_networks: Some(Default::default()),
41        }
42    }
43}