Skip to content

Commit

Permalink
Fix clippy and PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sakridge committed Apr 5, 2024
1 parent d25934a commit 9a26f36
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 28 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions gossip/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2831,10 +2831,6 @@ impl Node {
quic_config.clone(),
)
.unwrap();
let quic_config = SocketConfig {
reuseaddr: false,
reuseport: true,
};
let tpu_quic =
bind_more_with_config(tpu_quic, QUIC_ENDPOINTS, quic_config.clone()).unwrap();
let (gossip_port, (gossip, ip_echo)) =
Expand Down Expand Up @@ -3099,7 +3095,7 @@ impl Node {
quic_config.clone(),
);
let tpu_forwards_quic =
bind_more_with_config(tpu_forwards_quic, QUIC_ENDPOINTS, quic_config.clone()).unwrap();
bind_more_with_config(tpu_forwards_quic, QUIC_ENDPOINTS, quic_config).unwrap();

let (tpu_vote_port, tpu_vote_sockets) =
multi_bind_in_range(bind_ip_addr, port_range, 1).expect("tpu_vote multi_bind");
Expand Down
2 changes: 1 addition & 1 deletion net-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ fn udp_socket(_reuseaddr: bool) -> io::Result<Socket> {
}

#[cfg(any(windows, target_os = "ios"))]
fn udp_socket_with_config(config: SocketConfig) -> io::Result<Socket> {
fn udp_socket_with_config(_config: SocketConfig) -> io::Result<Socket> {
let sock = Socket::new(Domain::IPV4, Type::DGRAM, None)?;
Ok(sock)
}
Expand Down
1 change: 1 addition & 0 deletions streamer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ rand = { workspace = true }
rustls = { workspace = true, features = ["dangerous_configuration"] }
solana-measure = { workspace = true }
solana-metrics = { workspace = true }
solana-net-utils = { workspace = true }
solana-perf = { workspace = true }
solana-sdk = { workspace = true }
solana-transaction-metrics-tracker = { workspace = true }
Expand Down
36 changes: 14 additions & 22 deletions streamer/src/nonblocking/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1296,18 +1296,14 @@ pub mod test {
async_channel::unbounded as async_unbounded,
crossbeam_channel::{unbounded, Receiver},
quinn::{ClientConfig, IdleTimeout, TransportConfig},
socket2,
solana_net_utils::{bind_more_with_config, bind_to_with_config, SocketConfig},
solana_sdk::{
net::DEFAULT_TPU_COALESCE,
quic::{QUIC_KEEP_ALIVE, QUIC_MAX_TIMEOUT},
signature::Keypair,
signer::Signer,
},
std::{
collections::HashMap,
os::fd::{FromRawFd, IntoRawFd},
str::FromStr as _,
},
std::collections::HashMap,
tokio::time::sleep,
};

Expand Down Expand Up @@ -1356,6 +1352,16 @@ pub mod test {
config
}

fn make_quic_sockets() -> Vec<UdpSocket> {
const NUM_QUIC_SOCKETS: usize = 10;
let config = SocketConfig {
reuseaddr: false,
reuseport: true,
};
let socket = bind_to_with_config("127.0.0.1".parse().unwrap(), 0, config.clone()).unwrap();
bind_more_with_config(socket, NUM_QUIC_SOCKETS - 1, config).unwrap()
}

fn setup_quic_server(
option_staked_nodes: Option<StakedNodes>,
max_connections_per_peer: usize,
Expand All @@ -1366,28 +1372,14 @@ pub mod test {
SocketAddr,
Arc<StreamStats>,
) {
let sockets = (0..10)
.map(|_| {
let sock = socket2::Socket::new(
socket2::Domain::IPV4,
socket2::Type::DGRAM,
Some(socket2::Protocol::UDP),
)
.unwrap();
sock.set_reuse_port(true).unwrap();
sock.bind(&SocketAddr::from_str("127.0.0.1:42069").unwrap().into())
.unwrap();
unsafe { UdpSocket::from_raw_fd(sock.into_raw_fd()) }
})
.collect::<Vec<_>>();

let sockets = make_quic_sockets();
let exit = Arc::new(AtomicBool::new(false));
let (sender, receiver) = unbounded();
let keypair = Keypair::new();
let server_address = sockets[0].local_addr().unwrap();
let staked_nodes = Arc::new(RwLock::new(option_staked_nodes.unwrap_or_default()));
let (_, stats, t) = spawn_server_multi(
"one-million-sol",
"quic_streamer_test",
sockets,
&keypair,
sender,
Expand Down

0 comments on commit 9a26f36

Please sign in to comment.