feat(cli): add --disable-discovery (#597)

* redo add disable_discovery cli flag

* incorporate option into discovery test

* smol touch up

* rustmft

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
GeemoCandama
2022-12-30 03:56:59 -06:00
committed by GitHub
parent b5d8b6d4dd
commit f5ae970e63
5 changed files with 66 additions and 35 deletions

View File

@ -27,6 +27,7 @@ impl Config {
db: Arc<DB>,
chain_id: u64,
genesis_hash: H256,
disable_discovery: bool,
) -> NetworkConfig<ProviderImpl<DB>> {
let peer_config = reth_network::PeersConfig::default()
.with_trusted_nodes(self.peers.trusted_nodes.clone())
@ -36,6 +37,7 @@ impl Config {
.peer_config(peer_config)
.genesis_hash(genesis_hash)
.chain_id(chain_id)
.set_discovery(disable_discovery)
.build()
}
}

View File

@ -75,6 +75,10 @@ pub struct Command {
/// NOTE: This is a temporary flag
#[arg(long = "debug.tip")]
tip: Option<H256>,
/// Disable the discovery service.
#[arg(short, long)]
disable_discovery: bool,
}
impl Command {
@ -98,8 +102,10 @@ impl Command {
let consensus = Arc::new(BeaconConsensus::new(self.chain.consensus.clone()));
let genesis_hash = init_genesis(db.clone(), self.chain.genesis.clone())?;
let network =
config.network_config(db.clone(), chain_id, genesis_hash).start_network().await?;
let network = config
.network_config(db.clone(), chain_id, genesis_hash, self.disable_discovery)
.start_network()
.await?;
info!(peer_id = ?network.peer_id(), local_addr = %network.local_addr(), "Started p2p networking");