diff --git a/gossip/src/contact_info.rs b/gossip/src/contact_info.rs index 8c11ecb91f3d37..6e1522375dfa07 100644 --- a/gossip/src/contact_info.rs +++ b/gossip/src/contact_info.rs @@ -637,7 +637,7 @@ fn sanitize_entries(addrs: &[IpAddr], sockets: &[SocketEntry]) -> Result<(), Err // Verifies that the other socket is at QUIC_PORT_OFFSET from the first one. #[cfg(test)] -pub(crate) fn sanitize_quic_offset( +fn sanitize_quic_offset( socket: &Option, // udp other: &Option, // quic: udp + QUIC_PORT_OFFSET ) -> Result<(), Error> { @@ -647,7 +647,7 @@ pub(crate) fn sanitize_quic_offset( } // Returns the socket at QUIC_PORT_OFFSET from the given one. -pub(crate) fn get_quic_socket(socket: &SocketAddr) -> Result { +fn get_quic_socket(socket: &SocketAddr) -> Result { Ok(SocketAddr::new( socket.ip(), socket @@ -964,34 +964,23 @@ mod tests { old.serve_repair(Protocol::UDP).unwrap(), node.serve_repair(Protocol::UDP).unwrap() ); + assert_eq!(old.tpu().unwrap(), node.tpu(Protocol::UDP).unwrap()); assert_eq!( - old.tpu(Protocol::QUIC).unwrap(), - node.tpu(Protocol::QUIC).unwrap() - ); - assert_eq!( - old.tpu(Protocol::UDP).unwrap(), - node.tpu(Protocol::UDP).unwrap() - ); - assert_eq!( - old.tpu_forwards(Protocol::QUIC).unwrap(), - node.tpu_forwards(Protocol::QUIC).unwrap() + node.tpu(Protocol::QUIC).unwrap(), + SocketAddr::new( + old.tpu().unwrap().ip(), + old.tpu().unwrap().port() + QUIC_PORT_OFFSET + ) ); assert_eq!( - old.tpu_forwards(Protocol::UDP).unwrap(), + old.tpu_forwards().unwrap(), node.tpu_forwards(Protocol::UDP).unwrap() ); assert_eq!( node.tpu_forwards(Protocol::QUIC).unwrap(), SocketAddr::new( - old.tpu_forwards(Protocol::UDP).unwrap().ip(), - old.tpu_forwards(Protocol::UDP).unwrap().port() + QUIC_PORT_OFFSET - ) - ); - assert_eq!( - node.tpu(Protocol::QUIC).unwrap(), - SocketAddr::new( - old.tpu(Protocol::UDP).unwrap().ip(), - old.tpu(Protocol::UDP).unwrap().port() + QUIC_PORT_OFFSET + old.tpu_forwards().unwrap().ip(), + old.tpu_forwards().unwrap().port() + QUIC_PORT_OFFSET ) ); assert_eq!( diff --git a/gossip/src/legacy_contact_info.rs b/gossip/src/legacy_contact_info.rs index 165b72314c00a0..97ed47a1948f87 100644 --- a/gossip/src/legacy_contact_info.rs +++ b/gossip/src/legacy_contact_info.rs @@ -1,8 +1,5 @@ #[cfg(test)] -use crate::contact_info::{ - get_quic_socket, sanitize_quic_offset, sanitize_socket, ContactInfo, Error, Protocol, - SOCKET_ADDR_UNSPECIFIED, -}; +use crate::contact_info::{sanitize_socket, ContactInfo, Error, Protocol, SOCKET_ADDR_UNSPECIFIED}; use { crate::crds_data::MAX_WALLCLOCK, solana_pubkey::Pubkey, @@ -71,17 +68,6 @@ macro_rules! get_socket { Some(socket) } }; - (@quic $name:ident) => { - #[cfg(test)] - pub(crate) fn $name(&self, protocol: Protocol) -> Option { - let socket = self.$name; - sanitize_socket(&socket).ok()?; - match protocol { - Protocol::QUIC => get_quic_socket(&socket).ok(), - Protocol::UDP => Some(socket), - } - } - }; } #[macro_export] @@ -145,8 +131,8 @@ impl LegacyContactInfo { } get_socket!(tvu, tvu_quic); - get_socket!(@quic tpu); - get_socket!(@quic tpu_forwards); + get_socket!(tpu); + get_socket!(tpu_forwards); get_socket!(tpu_vote); get_socket!(rpc); get_socket!(rpc_pubsub); @@ -180,11 +166,6 @@ impl TryFrom<&ContactInfo> for LegacyContactInfo { node.$name($protocol).unwrap_or(SOCKET_ADDR_UNSPECIFIED) }; } - sanitize_quic_offset(&node.tpu(Protocol::UDP), &node.tpu(Protocol::QUIC))?; - sanitize_quic_offset( - &node.tpu_forwards(Protocol::UDP), - &node.tpu_forwards(Protocol::QUIC), - )?; Ok(Self { id: *node.pubkey(), gossip: unwrap_socket!(gossip),