diff --git a/service/src/lib.rs b/service/src/lib.rs index 42eeadf0d3c3..e9f5522c678c 100644 --- a/service/src/lib.rs +++ b/service/src/lib.rs @@ -278,7 +278,7 @@ macro_rules! new_full { $dispatch:ty, $informant_prefix:expr $(,)? ) => {{ - use sc_network::Event; + use sc_network::{config::NonReservedPeerMode, Event}; use sc_client_api::ExecutorProvider; use futures::stream::StreamExt; use sp_core::traits::BareCryptoStorePtr; @@ -294,6 +294,7 @@ macro_rules! new_full { }; let disable_grandpa = $config.disable_grandpa; let name = $config.network.node_name.clone(); + let non_reserved_peer_mode = $config.network.non_reserved_mode; let authority_discovery_enabled = $authority_discovery_enabled; let slot_duration = $slot_duration; @@ -455,6 +456,10 @@ macro_rules! new_full { _ => unreachable!("Due to outer matches! constraint; qed."), }; + // When a node is only allowed to connect to the configured reserved nodes + // (`NonReservedPeerMode::Deny`) there is no benefit in discovering other authorities. + let discover_authorities = non_reserved_peer_mode == NonReservedPeerMode::Accept; + let network = service.network(); let network_event_stream = network.event_stream("authority-discovery"); let dht_event_stream = network_event_stream.filter_map(|e| async move { match e { @@ -467,6 +472,7 @@ macro_rules! new_full { sentries, dht_event_stream, authority_discovery_role, + discover_authorities, service.prometheus_registry(), );