Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
service/src/lib: Disable authority discovery querying with reserved only
  • Loading branch information
mxinden committed Jun 15, 2020
commit e5cd3163af1eb46572e98e08d08e17c366bf44c6
8 changes: 7 additions & 1 deletion service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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 {
Expand All @@ -467,6 +472,7 @@ macro_rules! new_full {
sentries,
dht_event_stream,
authority_discovery_role,
discover_authorities,
service.prometheus_registry(),
);

Expand Down