mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 15:47:58 +00:00
Enable local addresses in DHT when chain type == Local | Development (#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!
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user