mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 00:58:11 -05:00
fix: use chain specific net dir for known peers (#2218)
This commit is contained in:
@@ -4,7 +4,7 @@ use crate::dirs::{KnownPeersPath, PlatformPath};
|
||||
use clap::Args;
|
||||
use reth_net_nat::NatResolver;
|
||||
use reth_network::NetworkConfigBuilder;
|
||||
use reth_primitives::{mainnet_nodes, ChainSpec, NodeRecord};
|
||||
use reth_primitives::{mainnet_nodes, Chain, ChainSpec, NodeRecord};
|
||||
use reth_staged_sync::Config;
|
||||
use secp256k1::SecretKey;
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
@@ -63,7 +63,7 @@ impl NetworkArgs {
|
||||
let chain_bootnodes = chain_spec.chain.bootnodes().unwrap_or_else(mainnet_nodes);
|
||||
|
||||
let network_config_builder = config
|
||||
.network_config(self.nat, self.persistent_peers_file(), secret_key)
|
||||
.network_config(self.nat, self.persistent_peers_file(chain_spec.chain), secret_key)
|
||||
.boot_nodes(self.bootnodes.clone().unwrap_or(chain_bootnodes))
|
||||
.chain_spec(chain_spec);
|
||||
|
||||
@@ -75,11 +75,15 @@ impl NetworkArgs {
|
||||
|
||||
impl NetworkArgs {
|
||||
/// If `no_persist_peers` is true then this returns the path to the persistent peers file
|
||||
pub fn persistent_peers_file(&self) -> Option<PathBuf> {
|
||||
///
|
||||
/// Uses the input chain to determine a chain-specific path to the known peers file.
|
||||
pub fn persistent_peers_file(&self, chain: Chain) -> Option<PathBuf> {
|
||||
if self.no_persist_peers {
|
||||
return None
|
||||
}
|
||||
Some(self.peers_file.clone().into())
|
||||
|
||||
let peers_file = self.peers_file.clone().with_chain(chain);
|
||||
Some(peers_file.into())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -177,7 +177,6 @@ impl Command {
|
||||
info!(target: "reth::cli", "Test transaction pool initialized");
|
||||
|
||||
info!(target: "reth::cli", "Connecting to P2P network");
|
||||
// let secret_key_path = self.p2p_secret_key.join(chain_prefix);
|
||||
let secret_key = get_secret_key(&self.p2p_secret_key)?;
|
||||
let network_config = self.load_network_config(
|
||||
&config,
|
||||
@@ -470,7 +469,7 @@ impl Command {
|
||||
.request_handler(client)
|
||||
.split_with_handle();
|
||||
|
||||
let known_peers_file = self.network.persistent_peers_file();
|
||||
let known_peers_file = self.network.persistent_peers_file(self.chain.chain);
|
||||
task_executor.spawn_critical_with_signal("p2p network task", |shutdown| {
|
||||
run_network_until_shutdown(shutdown, network, known_peers_file)
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user