mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
chore: delete duplicated node args types (#6169)
This commit is contained in:
@@ -122,6 +122,21 @@ impl NetworkArgs {
|
||||
|
||||
Some(peers_file)
|
||||
}
|
||||
|
||||
/// Sets the p2p port to zero, to allow the OS to assign a random unused port when
|
||||
/// the network components bind to a socket.
|
||||
pub fn with_unused_p2p_port(mut self) -> Self {
|
||||
self.port = 0;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the p2p and discovery ports to zero, allowing the OD to assign a random unused port
|
||||
/// when network components bind to sockets.
|
||||
pub fn with_unused_ports(mut self) -> Self {
|
||||
self = self.with_unused_p2p_port();
|
||||
self.discovery = self.discovery.with_unused_discovery_port();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for NetworkArgs {
|
||||
@@ -183,6 +198,13 @@ impl DiscoveryArgs {
|
||||
}
|
||||
network_config_builder
|
||||
}
|
||||
|
||||
/// Set the discovery port to zero, to allow the OS to assign a random unused port when
|
||||
/// discovery binds to the socket.
|
||||
pub fn with_unused_discovery_port(mut self) -> Self {
|
||||
self.port = 0;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for DiscoveryArgs {
|
||||
|
||||
@@ -17,6 +17,7 @@ use clap::{
|
||||
Arg, Args, Command,
|
||||
};
|
||||
use futures::TryFutureExt;
|
||||
use rand::Rng;
|
||||
use reth_network_api::{NetworkInfo, Peers};
|
||||
use reth_node_api::EngineTypes;
|
||||
use reth_provider::{
|
||||
@@ -220,6 +221,49 @@ impl RpcServerArgs {
|
||||
self.ipcpath = format!("{}-{}", self.ipcpath, instance);
|
||||
}
|
||||
|
||||
/// Set the http port to zero, to allow the OS to assign a random unused port when the rpc
|
||||
/// server binds to a socket.
|
||||
pub fn with_http_unused_port(mut self) -> Self {
|
||||
self.http_port = 0;
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the ws port to zero, to allow the OS to assign a random unused port when the rpc
|
||||
/// server binds to a socket.
|
||||
pub fn with_ws_unused_port(mut self) -> Self {
|
||||
self.ws_port = 0;
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the auth port to zero, to allow the OS to assign a random unused port when the rpc
|
||||
/// server binds to a socket.
|
||||
pub fn with_auth_unused_port(mut self) -> Self {
|
||||
self.auth_port = 0;
|
||||
self
|
||||
}
|
||||
|
||||
/// Append a random string to the ipc path, to prevent possible collisions when multiple nodes
|
||||
/// are being run on the same machine.
|
||||
pub fn with_ipc_random_path(mut self) -> Self {
|
||||
let random_string: String = rand::thread_rng()
|
||||
.sample_iter(rand::distributions::Alphanumeric)
|
||||
.take(8)
|
||||
.map(char::from)
|
||||
.collect();
|
||||
self.ipcpath = format!("{}-{}", self.ipcpath, random_string);
|
||||
self
|
||||
}
|
||||
|
||||
/// Configure all ports to be set to a random unused port when bound, and set the IPC path to a
|
||||
/// random path.
|
||||
pub fn with_unused_ports(mut self) -> Self {
|
||||
self = self.with_http_unused_port();
|
||||
self = self.with_ws_unused_port();
|
||||
self = self.with_auth_unused_port();
|
||||
self = self.with_ipc_random_path();
|
||||
self
|
||||
}
|
||||
|
||||
/// Configures and launches _all_ servers.
|
||||
///
|
||||
/// Returns the handles for the launched regular RPC server(s) (if any) and the server handle
|
||||
|
||||
@@ -102,13 +102,15 @@ where
|
||||
|
||||
/// Wrapper over DB that implements many useful DB queries.
|
||||
pub struct DbTool<'a, DB: Database> {
|
||||
pub(crate) db: &'a DB,
|
||||
pub(crate) chain: Arc<ChainSpec>,
|
||||
/// The database that the db tool will use.
|
||||
pub db: &'a DB,
|
||||
/// The [ChainSpec] that the db tool will use.
|
||||
pub chain: Arc<ChainSpec>,
|
||||
}
|
||||
|
||||
impl<'a, DB: Database> DbTool<'a, DB> {
|
||||
/// Takes a DB where the tables have already been created.
|
||||
pub(crate) fn new(db: &'a DB, chain: Arc<ChainSpec>) -> eyre::Result<Self> {
|
||||
pub fn new(db: &'a DB, chain: Arc<ChainSpec>) -> eyre::Result<Self> {
|
||||
Ok(Self { db, chain })
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
/// ```text
|
||||
/// 0.1.0 (defa64b2)
|
||||
/// ```
|
||||
pub(crate) const SHORT_VERSION: &str =
|
||||
pub const SHORT_VERSION: &str =
|
||||
concat!(env!("CARGO_PKG_VERSION"), " (", env!("VERGEN_GIT_SHA"), ")");
|
||||
|
||||
/// The long version information for reth.
|
||||
@@ -28,7 +28,7 @@ pub(crate) const SHORT_VERSION: &str =
|
||||
/// Build Timestamp: 2023-05-19T01:47:19.815651705Z
|
||||
/// Build Features: jemalloc
|
||||
/// ```
|
||||
pub(crate) const LONG_VERSION: &str = const_str::concat!(
|
||||
pub const LONG_VERSION: &str = const_str::concat!(
|
||||
"Version: ",
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
"\n",
|
||||
|
||||
Reference in New Issue
Block a user