Skip to content

Commit d5a5b4d

Browse files
committed
reduce scope
1 parent e9b1b87 commit d5a5b4d

File tree

2 files changed

+10
-31
lines changed

2 files changed

+10
-31
lines changed

net-utils/src/lib.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,6 @@ pub fn bind_common_in_range_with_config(
318318
range: PortRange,
319319
config: SocketConfig,
320320
) -> io::Result<(u16, (UdpSocket, TcpListener))> {
321-
assert!(
322-
!config.reuseport,
323-
"SO_REUSEPORT will allow this function to accidentally bind to occupied ports"
324-
);
325321
for port in range.0..range.1 {
326322
if let Ok((sock, listener)) = bind_common_with_config(ip_addr, port, config) {
327323
return Result::Ok((sock.local_addr().unwrap().port(), (sock, listener)));
@@ -356,11 +352,8 @@ pub fn bind_in_range_with_config(
356352
range: PortRange,
357353
config: SocketConfig,
358354
) -> io::Result<(u16, UdpSocket)> {
359-
assert!(
360-
!config.reuseport,
361-
"SO_REUSEPORT will allow this function to accidentally bind to occupied ports"
362-
);
363355
let sock = udp_socket_with_config(config)?;
356+
364357
for port in range.0..range.1 {
365358
let addr = SocketAddr::new(ip_addr, port);
366359

test-validator/src/lib.rs

+9-23
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use {
2020
geyser_plugin_manager::GeyserPluginManager, GeyserPluginManagerRequest,
2121
},
2222
solana_gossip::{
23-
cluster_info::{ClusterInfo, Node, NodeConfig},
23+
cluster_info::{ClusterInfo, Node},
2424
contact_info::Protocol,
2525
gossip_service::discover_cluster,
2626
socketaddr,
@@ -29,7 +29,7 @@ use {
2929
blockstore::create_new_ledger, blockstore_options::LedgerColumnOptions,
3030
create_new_tmp_ledger,
3131
},
32-
solana_net_utils::{find_available_port_in_range, PortRange},
32+
solana_net_utils::PortRange,
3333
solana_rpc::{rpc::JsonRpcConfig, rpc_pubsub_service::PubSubConfig},
3434
solana_rpc_client::{nonblocking, rpc_client::RpcClient},
3535
solana_rpc_client_api::request::MAX_MULTIPLE_ACCOUNTS,
@@ -63,7 +63,6 @@ use {
6363
fs::{self, remove_dir_all, File},
6464
io::Read,
6565
net::{IpAddr, Ipv4Addr, SocketAddr},
66-
num::NonZero,
6766
path::{Path, PathBuf},
6867
str::FromStr,
6968
sync::{Arc, RwLock},
@@ -949,30 +948,17 @@ impl TestValidator {
949948
.unwrap(),
950949
)?;
951950

952-
let node_config = NodeConfig {
953-
gossip_addr: config.node_config.gossip_addr,
954-
port_range: config.node_config.port_range,
955-
bind_ip_addr: config.node_config.bind_ip_addr,
956-
public_tpu_addr: None,
957-
public_tpu_forwards_addr: None,
958-
num_quic_endpoints: NonZero::new(1).unwrap(),
959-
num_tvu_receive_sockets: NonZero::new(1).unwrap(),
960-
num_tvu_retransmit_sockets: NonZero::new(1).unwrap(),
961-
};
962-
963-
let port_range = node_config.port_range;
964-
let mut node = Node::new_with_external_ip(&validator_identity.pubkey(), node_config);
965-
let addr = node.info.gossip().unwrap().ip();
951+
let mut node = Node::new_single_bind(
952+
&validator_identity.pubkey(),
953+
&config.node_config.gossip_addr,
954+
config.node_config.port_range,
955+
config.node_config.bind_ip_addr,
956+
);
966957
if let Some((rpc, rpc_pubsub)) = config.rpc_ports {
958+
let addr = node.info.gossip().unwrap().ip();
967959
node.info.set_rpc((addr, rpc)).unwrap();
968960
node.info.set_rpc_pubsub((addr, rpc_pubsub)).unwrap();
969-
} else {
970-
let rpc_port = find_available_port_in_range(addr, port_range).unwrap();
971-
let rpc_pubsub_port = find_available_port_in_range(addr, port_range).unwrap();
972-
node.info.set_rpc((addr, rpc_port)).unwrap();
973-
node.info.set_rpc_pubsub((addr, rpc_pubsub_port)).unwrap();
974961
}
975-
976962
let vote_account_address = validator_vote_account.pubkey();
977963
let rpc_url = format!("http://{}", node.info.rpc().unwrap());
978964
let rpc_pubsub_url = format!("ws://{}/", node.info.rpc_pubsub().unwrap());

0 commit comments

Comments
 (0)