diff --git a/gossip/src/contact_info.rs b/gossip/src/contact_info.rs index 092a12e9fd777f..fcf5b293867c86 100644 --- a/gossip/src/contact_info.rs +++ b/gossip/src/contact_info.rs @@ -521,7 +521,7 @@ pub(crate) fn sanitize_quic_offset( } // Returns the socket at QUIC_PORT_OFFSET from the given one. -fn get_quic_socket(socket: &SocketAddr) -> Result { +pub(crate) fn get_quic_socket(socket: &SocketAddr) -> Result { Ok(SocketAddr::new( socket.ip(), socket diff --git a/gossip/src/legacy_contact_info.rs b/gossip/src/legacy_contact_info.rs index 503b6ef8315902..f37f0dcfc3a649 100644 --- a/gossip/src/legacy_contact_info.rs +++ b/gossip/src/legacy_contact_info.rs @@ -1,7 +1,8 @@ use { crate::{ contact_info::{ - sanitize_quic_offset, sanitize_socket, socket_addr_unspecified, ContactInfo, Error, + get_quic_socket, sanitize_quic_offset, sanitize_socket, socket_addr_unspecified, + ContactInfo, Error, }, crds_value::MAX_WALLCLOCK, }, @@ -169,6 +170,10 @@ impl LegacyContactInfo { set_socket!(set_gossip, gossip); set_socket!(set_rpc, rpc); + pub fn tpu_quic(&self) -> Result { + self.tpu().and_then(|addr| get_quic_socket(&addr)) + } + fn is_valid_ip(addr: IpAddr) -> bool { !(addr.is_unspecified() || addr.is_multicast()) // || (addr.is_loopback() && !cfg_test)) diff --git a/rpc-client-api/src/response.rs b/rpc-client-api/src/response.rs index 4d8f19bb0e93e9..7591c58c036d32 100644 --- a/rpc-client-api/src/response.rs +++ b/rpc-client-api/src/response.rs @@ -294,8 +294,10 @@ pub struct RpcContactInfo { pub pubkey: String, /// Gossip port pub gossip: Option, - /// Tpu port + /// Tpu UDP port pub tpu: Option, + /// Tpu QUIC port + pub tpu_quic: Option, /// JSON RPC port pub rpc: Option, /// WebSocket PubSub port diff --git a/rpc-client/src/mock_sender.rs b/rpc-client/src/mock_sender.rs index ca9cd45691f390..5664c1be3f9e20 100644 --- a/rpc-client/src/mock_sender.rs +++ b/rpc-client/src/mock_sender.rs @@ -374,6 +374,7 @@ impl RpcSender for MockSender { pubkey: PUBKEY.to_string(), gossip: Some(SocketAddr::from(([10, 239, 6, 48], 8899))), tpu: Some(SocketAddr::from(([10, 239, 6, 48], 8856))), + tpu_quic: Some(SocketAddr::from(([10, 239, 6, 48], 8862))), rpc: Some(SocketAddr::from(([10, 239, 6, 48], 8899))), pubsub: Some(SocketAddr::from(([10, 239, 6, 48], 8900))), version: Some("1.0.0 c375ce1f".to_string()), diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index 59b71946e7ecd9..830b044f2809e1 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -3472,6 +3472,10 @@ pub mod rpc_full { .tpu() .ok() .filter(|addr| socket_addr_space.check(addr)), + tpu_quic: contact_info + .tpu_quic() + .ok() + .filter(|addr| socket_addr_space.check(addr)), rpc: contact_info .rpc() .ok() @@ -5138,6 +5142,7 @@ pub mod tests { "gossip": "127.0.0.1:8000", "shredVersion": 0u16, "tpu": "127.0.0.1:8003", + "tpuQuic": "127.0.0.1:8009", "rpc": format!("127.0.0.1:{}", rpc_port::DEFAULT_RPC_PORT), "pubsub": format!("127.0.0.1:{}", rpc_port::DEFAULT_RPC_PUBSUB_PORT), "version": null, @@ -5147,6 +5152,7 @@ pub mod tests { "gossip": "127.0.0.1:1235", "shredVersion": 0u16, "tpu": "127.0.0.1:1234", + "tpuQuic": "127.0.0.1:1240", "rpc": format!("127.0.0.1:{}", rpc_port::DEFAULT_RPC_PORT), "pubsub": format!("127.0.0.1:{}", rpc_port::DEFAULT_RPC_PUBSUB_PORT), "version": null,