mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(node-builder): use datadir from config (#8615)
This commit is contained in:
@ -246,9 +246,9 @@ impl NodeConfig {
|
||||
}
|
||||
|
||||
/// Get the network secret from the given data dir
|
||||
pub fn network_secret(&self, data_dir: &ChainPath<DataDirPath>) -> eyre::Result<SecretKey> {
|
||||
pub fn network_secret(&self) -> eyre::Result<SecretKey> {
|
||||
let network_secret_path =
|
||||
self.network.p2p_secret_key.clone().unwrap_or_else(|| data_dir.p2p_secret());
|
||||
self.network.p2p_secret_key.clone().unwrap_or_else(|| self.datadir().p2p_secret());
|
||||
debug!(target: "reth::cli", ?network_secret_path, "Loading p2p key file");
|
||||
let secret_key = get_secret_key(&network_secret_path)?;
|
||||
Ok(secret_key)
|
||||
@ -309,11 +309,10 @@ impl NodeConfig {
|
||||
client: C,
|
||||
executor: TaskExecutor,
|
||||
head: Head,
|
||||
data_dir: ChainPath<DataDirPath>,
|
||||
) -> eyre::Result<NetworkConfig<C>> {
|
||||
info!(target: "reth::cli", "Connecting to P2P network");
|
||||
let secret_key = self.network_secret(&data_dir)?;
|
||||
let default_peers_path = data_dir.known_peers();
|
||||
let secret_key = self.network_secret()?;
|
||||
let default_peers_path = self.datadir().known_peers();
|
||||
Ok(self.load_network_config(config, client, executor, head, secret_key, default_peers_path))
|
||||
}
|
||||
|
||||
@ -326,12 +325,11 @@ impl NodeConfig {
|
||||
client: C,
|
||||
executor: TaskExecutor,
|
||||
head: Head,
|
||||
data_dir: ChainPath<DataDirPath>,
|
||||
) -> eyre::Result<NetworkBuilder<C, (), ()>>
|
||||
where
|
||||
C: BlockNumReader,
|
||||
{
|
||||
let network_config = self.network_config(config, client, executor, head, data_dir)?;
|
||||
let network_config = self.network_config(config, client, executor, head)?;
|
||||
let builder = NetworkManager::builder(network_config).await?;
|
||||
Ok(builder)
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@ use reth_exex::ExExContext;
|
||||
use reth_network::{NetworkBuilder, NetworkConfig, NetworkHandle};
|
||||
use reth_node_api::{FullNodeTypes, FullNodeTypesAdapter, NodeTypes};
|
||||
use reth_node_core::{
|
||||
args::DatadirArgs,
|
||||
cli::config::{PayloadBuilderConfig, RethTransactionPoolConfig},
|
||||
dirs::{DataDirPath, MaybePlatformPath},
|
||||
node_config::NodeConfig,
|
||||
@ -173,7 +174,9 @@ impl<DB> NodeBuilder<DB> {
|
||||
task_executor: TaskExecutor,
|
||||
) -> WithLaunchContext<NodeBuilder<Arc<TempDatabase<DatabaseEnv>>>> {
|
||||
let path = MaybePlatformPath::<DataDirPath>::from(tempdir_path());
|
||||
self.config.datadir.datadir = path.clone();
|
||||
self.config = self
|
||||
.config
|
||||
.with_datadir_args(DatadirArgs { datadir: path.clone(), ..Default::default() });
|
||||
|
||||
let data_dir =
|
||||
path.unwrap_or_chain_default(self.config.chain.chain, self.config.datadir.clone());
|
||||
@ -467,7 +470,6 @@ impl<Node: FullNodeTypes> BuilderContext<Node> {
|
||||
self.provider.clone(),
|
||||
self.executor.clone(),
|
||||
self.head,
|
||||
self.config.datadir(),
|
||||
)
|
||||
}
|
||||
|
||||
@ -479,7 +481,6 @@ impl<Node: FullNodeTypes> BuilderContext<Node> {
|
||||
self.provider.clone(),
|
||||
self.executor.clone(),
|
||||
self.head,
|
||||
self.config.datadir(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user