Remove unnecessary FullnodeConfig::rpc_port option
This commit is contained in:
@ -223,33 +223,32 @@ fn main() {
|
|||||||
let (signer_service, signer_addr) = LocalVoteSignerService::new();
|
let (signer_service, signer_addr) = LocalVoteSignerService::new();
|
||||||
(Some(signer_service), signer_addr)
|
(Some(signer_service), signer_addr)
|
||||||
};
|
};
|
||||||
let rpc_port = if let Some(port) = matches.value_of("rpc_port") {
|
let (rpc_port, rpc_pubsub_port) = if let Some(port) = matches.value_of("rpc_port") {
|
||||||
let port_number = port.to_string().parse().expect("integer");
|
let port_number = port.to_string().parse().expect("integer");
|
||||||
if port_number == 0 {
|
if port_number == 0 {
|
||||||
eprintln!("Invalid RPC port requested: {:?}", port);
|
eprintln!("Invalid RPC port requested: {:?}", port);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
port_number
|
(port_number, port_number + 1)
|
||||||
} else {
|
} else {
|
||||||
solana_netutil::find_available_port_in_range(FULLNODE_PORT_RANGE)
|
(
|
||||||
.expect("unable to allocate rpc port")
|
solana_netutil::find_available_port_in_range(FULLNODE_PORT_RANGE)
|
||||||
|
.expect("unable to allocate rpc_port"),
|
||||||
|
solana_netutil::find_available_port_in_range(FULLNODE_PORT_RANGE)
|
||||||
|
.expect("unable to allocate rpc_pubsub_port"),
|
||||||
|
)
|
||||||
};
|
};
|
||||||
fullnode_config.rpc_port = Some(rpc_port);
|
|
||||||
let init_complete_file = matches.value_of("init_complete_file");
|
let init_complete_file = matches.value_of("init_complete_file");
|
||||||
fullnode_config.entry_stream = matches.value_of("entry_stream").map(|s| s.to_string());
|
fullnode_config.entry_stream = matches.value_of("entry_stream").map(|s| s.to_string());
|
||||||
|
|
||||||
let keypair = Arc::new(keypair);
|
let keypair = Arc::new(keypair);
|
||||||
let node = Node::new_with_external_ip(keypair.pubkey(), &gossip);
|
let mut node = Node::new_with_external_ip(keypair.pubkey(), &gossip);
|
||||||
let mut node_info = node.info.clone();
|
node.info.rpc.set_port(rpc_port);
|
||||||
|
node.info.rpc_pubsub.set_port(rpc_pubsub_port);
|
||||||
node_info.rpc.set_port(rpc_port);
|
|
||||||
node_info.rpc_pubsub.set_port(rpc_port + 1);
|
|
||||||
|
|
||||||
let mut leader_scheduler = LeaderScheduler::default();
|
let mut leader_scheduler = LeaderScheduler::default();
|
||||||
leader_scheduler.use_only_bootstrap_leader = use_only_bootstrap_leader;
|
leader_scheduler.use_only_bootstrap_leader = use_only_bootstrap_leader;
|
||||||
|
|
||||||
info!("Node ID: {}", node.info.id);
|
|
||||||
|
|
||||||
let vote_account;
|
let vote_account;
|
||||||
let vote_signer_option = if !no_signer {
|
let vote_signer_option = if !no_signer {
|
||||||
let vote_signer =
|
let vote_signer =
|
||||||
@ -263,6 +262,7 @@ fn main() {
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let gossip_addr = node.info.gossip;
|
||||||
let mut fullnode = Fullnode::new(
|
let mut fullnode = Fullnode::new(
|
||||||
node,
|
node,
|
||||||
keypair.clone(),
|
keypair.clone(),
|
||||||
@ -278,7 +278,7 @@ fn main() {
|
|||||||
if !no_signer {
|
if !no_signer {
|
||||||
let leader_node_info = loop {
|
let leader_node_info = loop {
|
||||||
info!("Looking for leader...");
|
info!("Looking for leader...");
|
||||||
match poll_gossip_for_leader(node_info.gossip, Some(10)) {
|
match poll_gossip_for_leader(gossip_addr, Some(10)) {
|
||||||
Ok(leader_node_info) => {
|
Ok(leader_node_info) => {
|
||||||
info!("Found leader: {:?}", leader_node_info);
|
info!("Found leader: {:?}", leader_node_info);
|
||||||
break leader_node_info;
|
break leader_node_info;
|
||||||
|
@ -67,7 +67,6 @@ pub enum FullnodeReturnType {
|
|||||||
|
|
||||||
pub struct FullnodeConfig {
|
pub struct FullnodeConfig {
|
||||||
pub sigverify_disabled: bool,
|
pub sigverify_disabled: bool,
|
||||||
pub rpc_port: Option<u16>,
|
|
||||||
pub entry_stream: Option<String>,
|
pub entry_stream: Option<String>,
|
||||||
pub storage_rotate_count: u64,
|
pub storage_rotate_count: u64,
|
||||||
}
|
}
|
||||||
@ -79,7 +78,6 @@ impl Default for FullnodeConfig {
|
|||||||
const NUM_HASHES_FOR_STORAGE_ROTATE: u64 = 1024;
|
const NUM_HASHES_FOR_STORAGE_ROTATE: u64 = 1024;
|
||||||
Self {
|
Self {
|
||||||
sigverify_disabled: false,
|
sigverify_disabled: false,
|
||||||
rpc_port: None,
|
|
||||||
entry_stream: None,
|
entry_stream: None,
|
||||||
storage_rotate_count: NUM_HASHES_FOR_STORAGE_ROTATE,
|
storage_rotate_count: NUM_HASHES_FOR_STORAGE_ROTATE,
|
||||||
}
|
}
|
||||||
@ -165,22 +163,11 @@ impl Fullnode {
|
|||||||
entrypoint_info_option: Option<&NodeInfo>,
|
entrypoint_info_option: Option<&NodeInfo>,
|
||||||
config: FullnodeConfig,
|
config: FullnodeConfig,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let mut rpc_addr = node.info.rpc;
|
info!("node info: {:?}", node.info);
|
||||||
let mut rpc_pubsub_addr = node.info.rpc_pubsub;
|
|
||||||
// If rpc_port == `None`, node will listen on the ports set in NodeInfo
|
|
||||||
if let Some(port) = config.rpc_port {
|
|
||||||
rpc_addr.set_port(port);
|
|
||||||
node.info.rpc = rpc_addr;
|
|
||||||
rpc_pubsub_addr.set_port(port + 1);
|
|
||||||
node.info.rpc_pubsub = rpc_pubsub_addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
info!("node rpc address: {}", node.info.rpc);
|
|
||||||
info!("node entrypoint_info: {:?}", entrypoint_info_option);
|
info!("node entrypoint_info: {:?}", entrypoint_info_option);
|
||||||
let local_gossip_addr = node.sockets.gossip.local_addr().unwrap();
|
|
||||||
info!(
|
info!(
|
||||||
"node local gossip address: {} (advertising {})",
|
"node local gossip address: {}",
|
||||||
local_gossip_addr, node.info.gossip
|
node.sockets.gossip.local_addr().unwrap()
|
||||||
);
|
);
|
||||||
|
|
||||||
let exit = Arc::new(AtomicBool::new(false));
|
let exit = Arc::new(AtomicBool::new(false));
|
||||||
@ -189,7 +176,7 @@ impl Fullnode {
|
|||||||
node.info.wallclock = timestamp();
|
node.info.wallclock = timestamp();
|
||||||
assert_eq!(keypair.pubkey(), node.info.id);
|
assert_eq!(keypair.pubkey(), node.info.id);
|
||||||
let cluster_info = Arc::new(RwLock::new(ClusterInfo::new_with_keypair(
|
let cluster_info = Arc::new(RwLock::new(ClusterInfo::new_with_keypair(
|
||||||
node.info,
|
node.info.clone(),
|
||||||
keypair.clone(),
|
keypair.clone(),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
@ -200,7 +187,7 @@ impl Fullnode {
|
|||||||
let drone_addr = {
|
let drone_addr = {
|
||||||
let mut entrypoint_drone_addr = match entrypoint_info_option {
|
let mut entrypoint_drone_addr = match entrypoint_info_option {
|
||||||
Some(entrypoint_info_info) => entrypoint_info_info.rpc,
|
Some(entrypoint_info_info) => entrypoint_info_info.rpc,
|
||||||
None => rpc_addr,
|
None => node.info.rpc,
|
||||||
};
|
};
|
||||||
entrypoint_drone_addr.set_port(solana_drone::drone::DRONE_PORT);
|
entrypoint_drone_addr.set_port(solana_drone::drone::DRONE_PORT);
|
||||||
entrypoint_drone_addr
|
entrypoint_drone_addr
|
||||||
@ -211,7 +198,7 @@ impl Fullnode {
|
|||||||
let rpc_service = JsonRpcService::new(
|
let rpc_service = JsonRpcService::new(
|
||||||
&bank,
|
&bank,
|
||||||
&cluster_info,
|
&cluster_info,
|
||||||
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), rpc_addr.port()),
|
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), node.info.rpc.port()),
|
||||||
drone_addr,
|
drone_addr,
|
||||||
storage_state.clone(),
|
storage_state.clone(),
|
||||||
);
|
);
|
||||||
@ -220,7 +207,7 @@ impl Fullnode {
|
|||||||
&bank,
|
&bank,
|
||||||
SocketAddr::new(
|
SocketAddr::new(
|
||||||
IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)),
|
IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)),
|
||||||
rpc_pubsub_addr.port(),
|
node.info.rpc_pubsub.port(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user