Add p2p listener port options for reth node (#1753)

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
This commit is contained in:
Aditya Pandey
2023-03-15 06:49:15 +05:30
committed by GitHub
parent a688fdb38d
commit 880759ac57
2 changed files with 14 additions and 1 deletions

View File

@@ -91,6 +91,10 @@ pub struct DiscoveryArgs {
/// Disable Discv4 discovery.
#[arg(long, conflicts_with = "disable_discovery")]
disable_discv4_discovery: bool,
/// The UDP port to use for P2P discovery/networking.
#[arg(long = "discovery.port")]
pub port: Option<u16>,
}
impl DiscoveryArgs {

View File

@@ -20,6 +20,7 @@ use reth_db::{
tables,
transaction::DbTx,
};
use reth_discv4::DEFAULT_DISCOVERY_PORT;
use reth_downloaders::{
bodies::bodies::BodiesDownloaderBuilder,
headers::reverse_headers::ReverseHeadersDownloaderBuilder,
@@ -52,7 +53,11 @@ use reth_stages::{
stages::{ExecutionStage, SenderRecoveryStage, TotalDifficultyStage, FINISH},
};
use reth_tasks::TaskExecutor;
use std::{net::SocketAddr, path::PathBuf, sync::Arc};
use std::{
net::{Ipv4Addr, SocketAddr, SocketAddrV4},
path::PathBuf,
sync::Arc,
};
use tokio::sync::{mpsc::unbounded_channel, watch};
use tracing::*;
@@ -417,6 +422,10 @@ impl Command {
.network_config(config, self.chain.clone())
.with_task_executor(Box::new(executor))
.set_head(head)
.listener_addr(SocketAddr::V4(SocketAddrV4::new(
Ipv4Addr::UNSPECIFIED,
self.network.discovery.port.unwrap_or(DEFAULT_DISCOVERY_PORT),
)))
.build(ShareableDatabase::new(db, self.chain.clone()))
}