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 a06bb5d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 25 deletions.
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
49 changes: 30 additions & 19 deletions streamer/src/nonblocking/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1296,18 +1296,13 @@ pub mod test {
async_channel::unbounded as async_unbounded,
crossbeam_channel::{unbounded, Receiver},
quinn::{ClientConfig, IdleTimeout, TransportConfig},
socket2,
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,17 +1351,21 @@ pub mod test {
config
}

fn setup_quic_server(
option_staked_nodes: Option<StakedNodes>,
max_connections_per_peer: usize,
) -> (
JoinHandle<()>,
Arc<AtomicBool>,
crossbeam_channel::Receiver<PacketBatch>,
SocketAddr,
Arc<StreamStats>,
) {
let sockets = (0..10)
#[cfg(any(windows, target_os = "ios"))]
fn make_quic_sockets() -> Vec<UdpSocket> {
let socket = UdpSocket::bind("127.0.0.1:0").unwrap();
vec![socket]
}

#[cfg(not(any(windows, target_os = "ios")))]
fn make_quic_sockets() -> Vec<UdpSocket> {
use std::{
os::fd::{FromRawFd, IntoRawFd},
str::FromStr,
};

const NUM_QUIC_SOCKETS: usize = 10;
(0..NUM_QUIC_SOCKETS)
.map(|_| {
let sock = socket2::Socket::new(
socket2::Domain::IPV4,
Expand All @@ -1375,12 +1374,24 @@ pub mod test {
)
.unwrap();
sock.set_reuse_port(true).unwrap();
sock.bind(&SocketAddr::from_str("127.0.0.1:42069").unwrap().into())
sock.bind(&SocketAddr::from_str("127.0.0.1:0").unwrap().into())
.unwrap();
unsafe { UdpSocket::from_raw_fd(sock.into_raw_fd()) }
})
.collect::<Vec<_>>();
.collect::<Vec<_>>()
}

fn setup_quic_server(
option_staked_nodes: Option<StakedNodes>,
max_connections_per_peer: usize,
) -> (
JoinHandle<()>,
Arc<AtomicBool>,
crossbeam_channel::Receiver<PacketBatch>,
SocketAddr,
Arc<StreamStats>,
) {
let sockets = make_quic_sockets();
let exit = Arc::new(AtomicBool::new(false));
let (sender, receiver) = unbounded();
let keypair = Keypair::new();
Expand Down

0 comments on commit a06bb5d

Please sign in to comment.