Skip to content

Commit

Permalink
remove a level of indirection by Arc<Vec<T>> -> Arc<[T]>
Browse files Browse the repository at this point in the history
  • Loading branch information
Folkert de Vries committed Nov 30, 2023
1 parent 3029a0d commit a81ce86
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions ntp-proto/src/nts_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ pub struct KeyExchangeServer {
state: State,
keyset: Arc<KeySet>,
#[cfg(feature = "nts-pool")]
pool_certificates: Arc<Vec<rustls::Certificate>>,
pool_certificates: Arc<[rustls::Certificate]>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -1552,7 +1552,7 @@ impl KeyExchangeServer {
pub fn new(
tls_config: Arc<rustls::ServerConfig>,
keyset: Arc<KeySet>,
pool_certificates: Arc<Vec<rustls::Certificate>>,
pool_certificates: Arc<[rustls::Certificate]>,
) -> Result<Self, KeyExchangeError> {
// Ensure we send only ntske/1 as alpn
debug_assert_eq!(tls_config.alpn_protocols, &[b"ntske/1".to_vec()]);
Expand Down Expand Up @@ -2475,7 +2475,7 @@ mod test {
let client =
KeyExchangeClient::new_without_tls_write("localhost".into(), clientconfig).unwrap();
let server =
KeyExchangeServer::new(Arc::new(serverconfig), keyset, Arc::new(pool_cert)).unwrap();
KeyExchangeServer::new(Arc::new(serverconfig), keyset, pool_cert.into()).unwrap();

(client, server)
}
Expand Down
8 changes: 4 additions & 4 deletions ntpd/src/daemon/keyexchange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ async fn key_exchange_server(
let listener = TcpListener::bind(&address).await?;

let config = build_server_config(certificate_chain, private_key)?;
let pool_certs = Arc::new(pool_certs);
let pool_certs = Arc::<[_]>::from(pool_certs);

loop {
let (stream, peer_addr) = listener.accept().await?;
Expand Down Expand Up @@ -334,7 +334,7 @@ where
io: IO,
config: Arc<rustls::ServerConfig>,
keyset: Arc<KeySet>,
pool_certs: Arc<Vec<rustls::Certificate>>,
pool_certs: Arc<[rustls::Certificate]>,
) -> Result<Self, KeyExchangeError> {
let data = BoundKeyExchangeServerData {
io,
Expand All @@ -349,7 +349,7 @@ where
io: IO,
config: Arc<rustls::ServerConfig>,
keyset: Arc<KeySet>,
pool_certs: Arc<Vec<rustls::Certificate>>,
pool_certs: Arc<[rustls::Certificate]>,
) -> Result<(), KeyExchangeError> {
let this = Self::new(io, config, keyset, pool_certs)?;

Expand Down Expand Up @@ -723,7 +723,7 @@ mod tests {
let private_key = private_key_from_bufread(pk.as_slice()).unwrap().unwrap();

let config = build_server_config(certificate_chain, private_key).unwrap();
let pool_certs = Arc::new(vec![]);
let pool_certs = Arc::<[_]>::from(vec![]);

let (stream, _) = listener.accept().await.unwrap();

Expand Down

0 comments on commit a81ce86

Please sign in to comment.