|
4 | 4 | banking_trace::TracedSender, sigverify::TransactionSigVerifier,
|
5 | 5 | sigverify_stage::SigVerifyStage,
|
6 | 6 | },
|
7 |
| - solana_net_utils::{bind_in_range_with_config, bind_more_with_config, SocketConfig}, |
| 7 | + solana_net_utils::{multi_bind_in_range_with_config, SocketConfig}, |
8 | 8 | solana_perf::packet::PacketBatch,
|
9 | 9 | solana_sdk::{quic::NotifyKeyUpdate, signature::Keypair},
|
10 | 10 | solana_streamer::{
|
|
13 | 13 | streamer::StakedNodes,
|
14 | 14 | },
|
15 | 15 | std::{
|
16 |
| - net::UdpSocket, |
| 16 | + net::{SocketAddr, UdpSocket}, |
17 | 17 | sync::{atomic::AtomicBool, Arc, Mutex, RwLock},
|
18 | 18 | thread::{self, JoinHandle},
|
19 | 19 | time::Duration,
|
@@ -56,26 +56,27 @@ impl Vortexor {
|
56 | 56 | pub fn create_tpu_sockets(
|
57 | 57 | bind_address: std::net::IpAddr,
|
58 | 58 | dynamic_port_range: (u16, u16),
|
| 59 | + tpu_address: Option<SocketAddr>, |
| 60 | + tpu_forward_address: Option<SocketAddr>, |
59 | 61 | num_quic_endpoints: usize,
|
60 | 62 | ) -> TpuSockets {
|
61 | 63 | let quic_config = SocketConfig::default().reuseport(true);
|
62 | 64 |
|
63 |
| - let (_, tpu_quic) = |
64 |
| - bind_in_range_with_config(bind_address, dynamic_port_range, quic_config) |
65 |
| - .expect("expected bind to succeed"); |
66 |
| - |
67 |
| - let tpu_quic_port = tpu_quic.local_addr().unwrap().port(); |
68 |
| - let tpu_quic = bind_more_with_config(tpu_quic, num_quic_endpoints, quic_config).unwrap(); |
69 |
| - |
70 |
| - let (_, tpu_quic_fwd) = bind_in_range_with_config( |
| 65 | + let tpu_quic = bind_sockets( |
71 | 66 | bind_address,
|
72 |
| - (tpu_quic_port.saturating_add(1), dynamic_port_range.1), |
| 67 | + dynamic_port_range, |
| 68 | + tpu_address, |
| 69 | + num_quic_endpoints, |
73 | 70 | quic_config,
|
74 |
| - ) |
75 |
| - .expect("expected bind to succeed"); |
| 71 | + ); |
76 | 72 |
|
77 |
| - let tpu_quic_fwd = |
78 |
| - bind_more_with_config(tpu_quic_fwd, num_quic_endpoints, quic_config).unwrap(); |
| 73 | + let tpu_quic_fwd = bind_sockets( |
| 74 | + bind_address, |
| 75 | + dynamic_port_range, |
| 76 | + tpu_forward_address, |
| 77 | + num_quic_endpoints, |
| 78 | + quic_config, |
| 79 | + ); |
79 | 80 |
|
80 | 81 | TpuSockets {
|
81 | 82 | tpu_quic,
|
@@ -177,3 +178,22 @@ impl Vortexor {
|
177 | 178 | Ok(())
|
178 | 179 | }
|
179 | 180 | }
|
| 181 | + |
| 182 | +/// Binds the sockets to the specified address and port range if address is Some. |
| 183 | +/// If the address is None, it binds to the specified bind_address and port range. |
| 184 | +fn bind_sockets( |
| 185 | + bind_address: std::net::IpAddr, |
| 186 | + port_range: (u16, u16), |
| 187 | + address: Option<SocketAddr>, |
| 188 | + num_quic_endpoints: usize, |
| 189 | + quic_config: SocketConfig, |
| 190 | +) -> Vec<UdpSocket> { |
| 191 | + let (bind_address, port_range) = address |
| 192 | + .map(|addr| (addr.ip(), (addr.port(), addr.port().saturating_add(1)))) |
| 193 | + .unwrap_or((bind_address, port_range)); |
| 194 | + |
| 195 | + let (_, sockets) = |
| 196 | + multi_bind_in_range_with_config(bind_address, port_range, quic_config, num_quic_endpoints) |
| 197 | + .expect("expected bind to succeed"); |
| 198 | + sockets |
| 199 | +} |
0 commit comments