Remove unnecessary FullnodeConfig::rpc_port option

This commit is contained in:
Michael Vines 2019-01-29 09:11:49 -08:00
parent ae7f169027
commit df136578d4
2 changed files with 20 additions and 33 deletions

View File

@ -223,33 +223,32 @@ fn main() {
let (signer_service, signer_addr) = LocalVoteSignerService::new();
(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");
if port_number == 0 {
eprintln!("Invalid RPC port requested: {:?}", port);
exit(1);
}
port_number
(port_number, port_number + 1)
} 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");
fullnode_config.entry_stream = matches.value_of("entry_stream").map(|s| s.to_string());
let keypair = Arc::new(keypair);
let 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_port + 1);
let mut node = Node::new_with_external_ip(keypair.pubkey(), &gossip);
node.info.rpc.set_port(rpc_port);
node.info.rpc_pubsub.set_port(rpc_pubsub_port);
let mut leader_scheduler = LeaderScheduler::default();
leader_scheduler.use_only_bootstrap_leader = use_only_bootstrap_leader;
info!("Node ID: {}", node.info.id);
let vote_account;
let vote_signer_option = if !no_signer {
let vote_signer =
@ -263,6 +262,7 @@ fn main() {
None
};
let gossip_addr = node.info.gossip;
let mut fullnode = Fullnode::new(
node,
keypair.clone(),
@ -278,7 +278,7 @@ fn main() {
if !no_signer {
let leader_node_info = loop {
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) => {
info!("Found leader: {:?}", leader_node_info);
break leader_node_info;

View File

@ -67,7 +67,6 @@ pub enum FullnodeReturnType {
pub struct FullnodeConfig {
pub sigverify_disabled: bool,
pub rpc_port: Option<u16>,
pub entry_stream: Option<String>,
pub storage_rotate_count: u64,
}
@ -79,7 +78,6 @@ impl Default for FullnodeConfig {
const NUM_HASHES_FOR_STORAGE_ROTATE: u64 = 1024;
Self {
sigverify_disabled: false,
rpc_port: None,
entry_stream: None,
storage_rotate_count: NUM_HASHES_FOR_STORAGE_ROTATE,
}
@ -165,22 +163,11 @@ impl Fullnode {
entrypoint_info_option: Option<&NodeInfo>,
config: FullnodeConfig,
) -> Self {
let mut rpc_addr = node.info.rpc;
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 info: {:?}", node.info);
info!("node entrypoint_info: {:?}", entrypoint_info_option);
let local_gossip_addr = node.sockets.gossip.local_addr().unwrap();
info!(
"node local gossip address: {} (advertising {})",
local_gossip_addr, node.info.gossip
"node local gossip address: {}",
node.sockets.gossip.local_addr().unwrap()
);
let exit = Arc::new(AtomicBool::new(false));
@ -189,7 +176,7 @@ impl Fullnode {
node.info.wallclock = timestamp();
assert_eq!(keypair.pubkey(), node.info.id);
let cluster_info = Arc::new(RwLock::new(ClusterInfo::new_with_keypair(
node.info,
node.info.clone(),
keypair.clone(),
)));
@ -200,7 +187,7 @@ impl Fullnode {
let drone_addr = {
let mut entrypoint_drone_addr = match entrypoint_info_option {
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
@ -211,7 +198,7 @@ impl Fullnode {
let rpc_service = JsonRpcService::new(
&bank,
&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,
storage_state.clone(),
);
@ -220,7 +207,7 @@ impl Fullnode {
&bank,
SocketAddr::new(
IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)),
rpc_pubsub_addr.port(),
node.info.rpc_pubsub.port(),
),
);