Skip to content

Commit fe5c6d8

Browse files
authored
fix: check additional settings when enabling discv5 (#16643)
1 parent f7db031 commit fe5c6d8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

crates/node/core/src/args/network.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ impl DiscoveryArgs {
441441
network_config_builder = network_config_builder.disable_nat();
442442
}
443443

444-
if !self.disable_discovery && self.enable_discv5_discovery {
444+
if self.should_enable_discv5() {
445445
network_config_builder = network_config_builder
446446
.discovery_v5(self.discovery_v5_builder(rlpx_tcp_socket, boot_nodes));
447447
}
@@ -490,6 +490,17 @@ impl DiscoveryArgs {
490490
.bootstrap_lookup_countdown(*discv5_bootstrap_lookup_countdown)
491491
}
492492

493+
/// Returns true if discv5 discovery should be configured
494+
const fn should_enable_discv5(&self) -> bool {
495+
if self.disable_discovery {
496+
return false;
497+
}
498+
499+
self.enable_discv5_discovery ||
500+
self.discv5_addr.is_some() ||
501+
self.discv5_addr_ipv6.is_some()
502+
}
503+
493504
/// Set the discovery port to zero, to allow the OS to assign a random unused port when
494505
/// discovery binds to the socket.
495506
pub const fn with_unused_discovery_port(mut self) -> Self {

0 commit comments

Comments
 (0)