refactor: unify all chains confs (#747)

Co-authored-by: Bjerg <onbjerg@users.noreply.github.com>
This commit is contained in:
Aurélien
2023-01-17 16:47:34 +01:00
committed by GitHub
parent 55d1db0c1d
commit f9de425ad8
33 changed files with 28324 additions and 737 deletions

View File

@ -2,10 +2,7 @@
use crate::{
config::Config,
dirs::{ConfigPath, PlatformPath},
utils::{
chainspec::{chain_spec_value_parser, ChainSpecification},
hash_or_num_value_parser,
},
utils::{chainspec::chain_spec_value_parser, hash_or_num_value_parser},
};
use backon::{ConstantBackoff, Retryable};
use clap::{Parser, Subcommand};
@ -15,7 +12,7 @@ use reth_interfaces::p2p::{
headers::client::{HeadersClient, HeadersRequest},
};
use reth_network::FetchClient;
use reth_primitives::{BlockHashOrNumber, Header, NodeRecord, SealedHeader};
use reth_primitives::{BlockHashOrNumber, ChainSpec, NodeRecord, SealedHeader};
use std::sync::Arc;
/// `reth p2p` command
@ -40,7 +37,7 @@ pub struct Command {
default_value = "mainnet",
value_parser = chain_spec_value_parser
)]
chain: ChainSpecification,
chain: ChainSpec,
/// Disable the discovery service.
#[arg(short, long)]
@ -86,10 +83,6 @@ impl Command {
let mut config: Config = confy::load_path(&self.config).unwrap_or_default();
let chain_id = self.chain.consensus.chain_id;
let genesis: Header = self.chain.genesis.clone().into();
let genesis_hash = genesis.hash_slow();
if let Some(peer) = self.trusted_peer {
config.peers.trusted_nodes.insert(peer);
}
@ -101,7 +94,7 @@ impl Command {
config.peers.connect_trusted_nodes_only = self.trusted_only;
let network = config
.network_config(noop_db, chain_id, genesis_hash, self.disable_discovery, None)
.network_config(noop_db, self.chain.clone(), self.disable_discovery, None)
.start_network()
.await?;