feat: configure interval for trusted peer DNS resolution (#16647)

This commit is contained in:
Muhammed Kadir Yücel
2025-06-04 14:41:55 +03:00
committed by GitHub
parent 74bde8adee
commit 249fa36432
3 changed files with 7 additions and 2 deletions

View File

@@ -131,6 +131,9 @@ pub struct PeersConfig {
/// Connect to or accept from trusted nodes only?
#[cfg_attr(feature = "serde", serde(alias = "connect_trusted_nodes_only"))]
pub trusted_nodes_only: bool,
/// Interval to update trusted nodes DNS resolution
#[cfg_attr(feature = "serde", serde(with = "humantime_serde"))]
pub trusted_nodes_resolution_interval: Duration,
/// Maximum number of backoff attempts before we give up on a peer and dropping.
///
/// The max time spent of a peer before it's removed from the set is determined by the
@@ -177,6 +180,7 @@ impl Default for PeersConfig {
backoff_durations: Default::default(),
trusted_nodes: Default::default(),
trusted_nodes_only: false,
trusted_nodes_resolution_interval: Duration::from_secs(60 * 60),
basic_nodes: Default::default(),
max_backoff_count: 5,
incoming_ip_throttle_duration: INBOUND_IP_THROTTLE_DURATION,

View File

@@ -103,6 +103,7 @@ impl PeersManager {
backoff_durations,
trusted_nodes,
trusted_nodes_only,
trusted_nodes_resolution_interval,
basic_nodes,
max_backoff_count,
incoming_ip_throttle_duration,
@@ -141,7 +142,7 @@ impl PeersManager {
trusted_peer_ids,
trusted_peers_resolver: TrustedPeersResolver::new(
trusted_nodes,
tokio::time::interval(Duration::from_secs(60 * 60)), // 1 hour
tokio::time::interval(trusted_nodes_resolution_interval), // 1 hour
),
manager_tx,
handle_rx: UnboundedReceiverStream::new(handle_rx),

View File

@@ -13,7 +13,7 @@ use tracing::warn;
/// It returns a resolved (`PeerId`, `NodeRecord`) update when one of its inflight tasks completes.
#[derive(Debug)]
pub struct TrustedPeersResolver {
/// The timer that triggers a new resolution cycle.
/// The list of trusted peers to resolve.
pub trusted_peers: Vec<TrustedPeer>,
/// The timer that triggers a new resolution cycle.
pub interval: Interval,