Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
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
14 changes: 11 additions & 3 deletions client/cli/src/params/network_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use sc_network::{
config::{NetworkConfiguration, NodeKeyConfig, NonReservedPeerMode, TransportConfig},
multiaddr::Protocol,
};
use sc_service::{ChainSpec, config::{Multiaddr, MultiaddrWithPeerId}};
use sc_service::{ChainSpec, ChainType, config::{Multiaddr, MultiaddrWithPeerId}};
use std::path::PathBuf;
use structopt::StructOpt;

Expand Down Expand Up @@ -94,7 +94,8 @@ pub struct NetworkParams {

/// Enable peer discovery on local networks.
///
/// By default this option is true for `--dev` and false otherwise.
/// By default this option is `true` for `--dev` or when the chain type is `Local`/`Development`
/// and false otherwise.
#[structopt(long)]
pub discover_local: bool,

Expand Down Expand Up @@ -139,6 +140,13 @@ impl NetworkParams {
let mut boot_nodes = chain_spec.boot_nodes().to_vec();
boot_nodes.extend(self.bootnodes.clone());

let chain_type = chain_spec.chain_type();
// Activate if the user explicitly requested local discovery, `--dev` is given or the
// chain type is `Local`/`Development`
let allow_non_globals_in_dht = self.discover_local
|| is_dev
|| matches!(chain_type, ChainType::Local | ChainType::Development);

NetworkConfiguration {
boot_nodes,
net_config_path,
Expand All @@ -163,7 +171,7 @@ impl NetworkParams {
wasm_external_transport: None,
},
max_parallel_downloads: self.max_parallel_downloads,
allow_non_globals_in_dht: self.discover_local || is_dev,
allow_non_globals_in_dht,
kademlia_disjoint_query_paths: self.kademlia_disjoint_query_paths,
}
}
Expand Down