feat: allows to disable dns and discv4 discovery separately (#1406)

This commit is contained in:
Aurélien
2023-02-16 19:30:47 +01:00
committed by GitHub
parent 8db091e8e0
commit d2ec304bd3
4 changed files with 58 additions and 22 deletions

View File

@ -1,5 +1,8 @@
//! P2P Debugging tool
use crate::dirs::{ConfigPath, PlatformPath};
use crate::{
args::DiscoveryArgs,
dirs::{ConfigPath, PlatformPath},
};
use backon::{ConstantBackoff, Retryable};
use clap::{Parser, Subcommand};
use reth_db::mdbx::{Env, EnvKind, WriteMap};
@ -42,8 +45,8 @@ pub struct Command {
chain: ChainSpec,
/// Disable the discovery service.
#[arg(short, long)]
disable_discovery: bool,
#[command(flatten)]
pub discovery: DiscoveryArgs,
/// Target trusted peer
#[arg(long)]
@ -98,10 +101,12 @@ impl Command {
config.peers.connect_trusted_nodes_only = self.trusted_only;
let network = config
.network_config(self.nat, None)
.set_discovery(self.disable_discovery)
.chain_spec(self.chain.clone())
let mut network_config_builder =
config.network_config(self.nat, None).chain_spec(self.chain.clone());
network_config_builder = self.discovery.apply_to_builder(network_config_builder);
let network = network_config_builder
.build(Arc::new(ShareableDatabase::new(noop_db)))
.start_network()
.await?;