Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Enable local addresses in DHT when chain type == Local | `Developme…
Browse files Browse the repository at this point in the history
…nt` (#7538)

* Enable local addresses in DHT when chain type == `Local` | `Development`

This pr changes when to add local addresses to DHT. Instead of only
checking if `--discover-local` and `--dev` are present, we now also
check if the chain type is `Local` or `Development`.

* Update the docs!
  • Loading branch information
bkchr authored Nov 13, 2020
1 parent 1c0f76b commit 5222a8f
Showing 1 changed file with 11 additions and 3 deletions.
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

0 comments on commit 5222a8f

Please sign in to comment.