72
72
} ,
73
73
solana_streamer:: {
74
74
packet,
75
+ quic:: DEFAULT_QUIC_ENDPOINTS ,
75
76
socket:: SocketAddrSpace ,
76
77
streamer:: { PacketBatchReceiver , PacketBatchSender } ,
77
78
} ,
@@ -2897,11 +2898,10 @@ pub struct NodeConfig {
2897
2898
pub public_tpu_forwards_addr : Option < SocketAddr > ,
2898
2899
/// The number of TVU sockets to create
2899
2900
pub num_tvu_sockets : NonZeroUsize ,
2901
+ /// The number of QUIC tpu endpoints
2902
+ pub num_quic_endpoints : NonZeroUsize ,
2900
2903
}
2901
2904
2902
- // This will be adjusted and parameterized in follow-on PRs.
2903
- const QUIC_ENDPOINTS : usize = 1 ;
2904
-
2905
2905
#[ derive( Debug ) ]
2906
2906
pub struct Node {
2907
2907
pub info : ContactInfo ,
@@ -2913,7 +2913,15 @@ impl Node {
2913
2913
let pubkey = solana_sdk:: pubkey:: new_rand ( ) ;
2914
2914
Self :: new_localhost_with_pubkey ( & pubkey)
2915
2915
}
2916
+
2916
2917
pub fn new_localhost_with_pubkey ( pubkey : & Pubkey ) -> Self {
2918
+ Self :: new_localhost_with_pubkey_and_quic_endpoints ( pubkey, DEFAULT_QUIC_ENDPOINTS )
2919
+ }
2920
+
2921
+ pub fn new_localhost_with_pubkey_and_quic_endpoints (
2922
+ pubkey : & Pubkey ,
2923
+ num_quic_endpoints : usize ,
2924
+ ) -> Self {
2917
2925
let localhost_ip_addr = IpAddr :: V4 ( Ipv4Addr :: LOCALHOST ) ;
2918
2926
let localhost_bind_addr = format ! ( "{localhost_ip_addr:?}:0" ) ;
2919
2927
let unspecified_bind_addr = format ! ( "{:?}:0" , IpAddr :: V4 ( Ipv4Addr :: UNSPECIFIED ) ) ;
@@ -2931,7 +2939,7 @@ impl Node {
2931
2939
)
2932
2940
. unwrap ( ) ;
2933
2941
let tpu_quic =
2934
- bind_more_with_config ( tpu_quic, QUIC_ENDPOINTS , quic_config. clone ( ) ) . unwrap ( ) ;
2942
+ bind_more_with_config ( tpu_quic, num_quic_endpoints , quic_config. clone ( ) ) . unwrap ( ) ;
2935
2943
let ( gossip_port, ( gossip, ip_echo) ) =
2936
2944
bind_common_in_range ( localhost_ip_addr, port_range) . unwrap ( ) ;
2937
2945
let gossip_addr = SocketAddr :: new ( localhost_ip_addr, gossip_port) ;
@@ -2947,7 +2955,7 @@ impl Node {
2947
2955
)
2948
2956
. unwrap ( ) ;
2949
2957
let tpu_forwards_quic =
2950
- bind_more_with_config ( tpu_forwards_quic, QUIC_ENDPOINTS , quic_config) . unwrap ( ) ;
2958
+ bind_more_with_config ( tpu_forwards_quic, num_quic_endpoints , quic_config) . unwrap ( ) ;
2951
2959
let tpu_vote = UdpSocket :: bind ( & localhost_bind_addr) . unwrap ( ) ;
2952
2960
let repair = UdpSocket :: bind ( & localhost_bind_addr) . unwrap ( ) ;
2953
2961
let rpc_port = find_available_port_in_range ( localhost_ip_addr, port_range) . unwrap ( ) ;
@@ -3068,7 +3076,7 @@ impl Node {
3068
3076
)
3069
3077
. unwrap ( ) ;
3070
3078
let tpu_quic =
3071
- bind_more_with_config ( tpu_quic, QUIC_ENDPOINTS , quic_config. clone ( ) ) . unwrap ( ) ;
3079
+ bind_more_with_config ( tpu_quic, DEFAULT_QUIC_ENDPOINTS , quic_config. clone ( ) ) . unwrap ( ) ;
3072
3080
let ( ( tpu_forwards_port, tpu_forwards) , ( _tpu_forwards_quic_port, tpu_forwards_quic) ) =
3073
3081
bind_two_in_range_with_offset_and_config (
3074
3082
bind_ip_addr,
@@ -3079,7 +3087,7 @@ impl Node {
3079
3087
)
3080
3088
. unwrap ( ) ;
3081
3089
let tpu_forwards_quic =
3082
- bind_more_with_config ( tpu_forwards_quic, QUIC_ENDPOINTS , quic_config) . unwrap ( ) ;
3090
+ bind_more_with_config ( tpu_forwards_quic, DEFAULT_QUIC_ENDPOINTS , quic_config) . unwrap ( ) ;
3083
3091
let ( tpu_vote_port, tpu_vote) = Self :: bind ( bind_ip_addr, port_range) ;
3084
3092
let ( _, retransmit_socket) = Self :: bind ( bind_ip_addr, port_range) ;
3085
3093
let ( _, repair) = Self :: bind ( bind_ip_addr, port_range) ;
@@ -3151,6 +3159,7 @@ impl Node {
3151
3159
public_tpu_addr,
3152
3160
public_tpu_forwards_addr,
3153
3161
num_tvu_sockets,
3162
+ num_quic_endpoints,
3154
3163
} = config;
3155
3164
3156
3165
let ( gossip_port, ( gossip, ip_echo) ) =
@@ -3170,7 +3179,7 @@ impl Node {
3170
3179
quic_config. clone ( ) ,
3171
3180
) ;
3172
3181
let tpu_quic =
3173
- bind_more_with_config ( tpu_quic, QUIC_ENDPOINTS , quic_config. clone ( ) ) . unwrap ( ) ;
3182
+ bind_more_with_config ( tpu_quic, num_quic_endpoints . get ( ) , quic_config. clone ( ) ) . unwrap ( ) ;
3174
3183
3175
3184
let ( tpu_forwards_port, tpu_forwards_sockets) =
3176
3185
multi_bind_in_range ( bind_ip_addr, port_range, 8 ) . expect ( "tpu_forwards multi_bind" ) ;
@@ -3183,8 +3192,12 @@ impl Node {
3183
3192
) ,
3184
3193
quic_config. clone ( ) ,
3185
3194
) ;
3186
- let tpu_forwards_quic =
3187
- bind_more_with_config ( tpu_forwards_quic, QUIC_ENDPOINTS , quic_config. clone ( ) ) . unwrap ( ) ;
3195
+ let tpu_forwards_quic = bind_more_with_config (
3196
+ tpu_forwards_quic,
3197
+ num_quic_endpoints. get ( ) ,
3198
+ quic_config. clone ( ) ,
3199
+ )
3200
+ . unwrap ( ) ;
3188
3201
3189
3202
let ( tpu_vote_port, tpu_vote_sockets) =
3190
3203
multi_bind_in_range ( bind_ip_addr, port_range, 1 ) . expect ( "tpu_vote multi_bind" ) ;
@@ -3399,6 +3412,8 @@ mod tests {
3399
3412
sync:: Arc ,
3400
3413
} ,
3401
3414
} ;
3415
+ const DEFAULT_NUM_QUIC_ENDPOINTS : NonZeroUsize =
3416
+ unsafe { NonZeroUsize :: new_unchecked ( DEFAULT_QUIC_ENDPOINTS ) } ;
3402
3417
3403
3418
#[ test]
3404
3419
fn test_gossip_node ( ) {
@@ -3813,6 +3828,7 @@ mod tests {
3813
3828
public_tpu_addr : None ,
3814
3829
public_tpu_forwards_addr : None ,
3815
3830
num_tvu_sockets : MINIMUM_NUM_TVU_SOCKETS ,
3831
+ num_quic_endpoints : DEFAULT_NUM_QUIC_ENDPOINTS ,
3816
3832
} ;
3817
3833
3818
3834
let node = Node :: new_with_external_ip ( & solana_sdk:: pubkey:: new_rand ( ) , config) ;
@@ -3835,6 +3851,7 @@ mod tests {
3835
3851
public_tpu_addr : None ,
3836
3852
public_tpu_forwards_addr : None ,
3837
3853
num_tvu_sockets : MINIMUM_NUM_TVU_SOCKETS ,
3854
+ num_quic_endpoints : DEFAULT_NUM_QUIC_ENDPOINTS ,
3838
3855
} ;
3839
3856
3840
3857
let node = Node :: new_with_external_ip ( & solana_sdk:: pubkey:: new_rand ( ) , config) ;
0 commit comments