mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add secret-key command line option (#1946)
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
//! P2P Debugging tool
|
||||
use crate::{
|
||||
args::DiscoveryArgs,
|
||||
dirs::{ConfigPath, PlatformPath},
|
||||
args::{get_secret_key, DiscoveryArgs},
|
||||
dirs::{ConfigPath, PlatformPath, SecretKeyPath},
|
||||
utils::get_single_header,
|
||||
};
|
||||
use backon::{ConstantBuilder, Retryable};
|
||||
@ -41,6 +41,12 @@ pub struct Command {
|
||||
)]
|
||||
chain: Arc<ChainSpec>,
|
||||
|
||||
/// Secret key to use for this node.
|
||||
///
|
||||
/// This also will deterministically set the peer ID.
|
||||
#[arg(long, value_name = "PATH", global = true, required = false, default_value_t)]
|
||||
p2p_secret_key: PlatformPath<SecretKeyPath>,
|
||||
|
||||
/// Disable the discovery service.
|
||||
#[command(flatten)]
|
||||
pub discovery: DiscoveryArgs,
|
||||
@ -98,8 +104,10 @@ impl Command {
|
||||
|
||||
config.peers.connect_trusted_nodes_only = self.trusted_only;
|
||||
|
||||
let p2p_secret_key = get_secret_key(&self.p2p_secret_key)?;
|
||||
|
||||
let mut network_config_builder =
|
||||
config.network_config(self.nat, None).chain_spec(self.chain.clone());
|
||||
config.network_config(self.nat, None, p2p_secret_key).chain_spec(self.chain.clone());
|
||||
|
||||
network_config_builder = self.discovery.apply_to_builder(network_config_builder);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user