validator: add --private-rpc flag (bp #8037) (#8054)

automerge
This commit is contained in:
mergify[bot]
2020-01-30 20:44:53 -08:00
committed by GitHub
parent 81add4d6bf
commit c85c4699aa
5 changed files with 145 additions and 105 deletions

View File

@@ -496,6 +496,12 @@ pub fn main() {
.validator(port_validator)
.help("RPC port to use for this node"),
)
.arg(
Arg::with_name("private_rpc")
.long("--private-rpc")
.takes_value(false)
.help("Do not publish the RPC port for use by other nodes")
)
.arg(
Arg::with_name("enable_rpc_exit")
.long("enable-rpc-exit")
@@ -657,7 +663,7 @@ pub fn main() {
let cuda = matches.is_present("cuda");
let no_genesis_fetch = matches.is_present("no_genesis_fetch");
let no_snapshot_fetch = matches.is_present("no_snapshot_fetch");
let rpc_port = value_t!(matches, "rpc_port", u16);
let private_rpc = matches.is_present("private_rpc");
// Canonicalize ledger path to avoid issues with symlink creation
let _ = fs::create_dir_all(&ledger_path);
@@ -683,6 +689,9 @@ pub fn main() {
solana_net_utils::parse_host_port(address).expect("failed to parse faucet address")
}),
},
rpc_ports: value_t!(matches, "rpc_port", u16)
.ok()
.map(|rpc_port| (rpc_port, rpc_port + 1)),
voting_disabled: matches.is_present("no_voting"),
wait_for_supermajority: !matches.is_present("no_wait_for_supermajority"),
..ValidatorConfig::default()
@@ -852,12 +861,14 @@ pub fn main() {
let mut tcp_ports = vec![];
let mut node =
Node::new_with_external_ip(&identity_keypair.pubkey(), &gossip_addr, dynamic_port_range);
if let Ok(rpc_port) = rpc_port {
let rpc_pubsub_port = rpc_port + 1;
node.info.rpc = SocketAddr::new(node.info.gossip.ip(), rpc_port);
node.info.rpc_pubsub = SocketAddr::new(node.info.gossip.ip(), rpc_pubsub_port);
tcp_ports = vec![rpc_port, rpc_pubsub_port];
};
if !private_rpc {
if let Some((rpc_port, rpc_pubsub_port)) = validator_config.rpc_ports {
node.info.rpc = SocketAddr::new(node.info.gossip.ip(), rpc_port);
node.info.rpc_pubsub = SocketAddr::new(node.info.gossip.ip(), rpc_pubsub_port);
tcp_ports = vec![rpc_port, rpc_pubsub_port];
}
}
if let Some(ref cluster_entrypoint) = cluster_entrypoint {
let udp_sockets = vec![&node.sockets.gossip, &node.sockets.repair];