chore: add disable discovery options (#1182)

This commit is contained in:
Matthias Seitz
2023-02-06 03:37:42 +01:00
committed by GitHub
parent ba70b3b7ef
commit c6a7d3637e
2 changed files with 15 additions and 1 deletions

View File

@@ -238,12 +238,24 @@ impl NetworkConfigBuilder {
self
}
/// Disables Discv4 discovery.
pub fn no_discv4_discovery(mut self) -> Self {
self.discovery_v4_builder = None;
self
}
/// Sets the dns discovery config to use.
pub fn dns_discovery(mut self, config: DnsDiscoveryConfig) -> Self {
self.dns_discovery_config = Some(config);
self
}
/// Disables DNS discovery
pub fn no_dns_discovery(mut self) -> Self {
self.dns_discovery_config = None;
self
}
/// Sets the boot nodes.
pub fn boot_nodes(mut self, nodes: impl IntoIterator<Item = NodeRecord>) -> Self {
self.boot_nodes = nodes.into_iter().collect();
@@ -258,9 +270,10 @@ impl NetworkConfigBuilder {
self
}
/// disables discovery.
/// Disables all discovery services.
pub fn disable_discovery(&mut self) {
self.discovery_v4_builder = None;
self.dns_discovery_config = None;
}
/// Consumes the type and creates the actual [`NetworkConfig`]

View File

@@ -308,6 +308,7 @@ where
NetworkConfigBuilder::new(secret_key)
.listener_addr(SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, 0)))
.discovery_addr(SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, 0)))
.no_dns_discovery()
}
}