@@ -20,6 +20,7 @@ use discv5::{
2020 rpc:: RequestId ,
2121} ;
2222use futures:: { channel:: oneshot, future:: join_all, prelude:: * } ;
23+ use lazy_static:: lazy_static;
2324use parking_lot:: RwLock ;
2425use rand:: seq:: { IteratorRandom , SliceRandom } ;
2526use smallvec:: SmallVec ;
@@ -82,16 +83,10 @@ const EXPECTED_NON_EMPTY_BUCKETS: usize = 17;
8283/// Bucket refresh lookup interval in seconds
8384const BUCKET_REFRESH_INTERVAL_SECS : u64 = 60 ;
8485
85- /// The default configuration to use for uTP connections.
86- pub const UTP_CONN_CFG : ConnectionConfig = ConnectionConfig {
87- max_packet_size : 1024 ,
88- max_conn_attempts : 3 ,
89- max_idle_timeout : Duration :: from_secs ( 32 ) ,
90- max_timeout : Duration :: from_secs ( 60 ) ,
91- initial_timeout : Duration :: from_millis ( 1500 ) ,
92- min_timeout : Duration :: from_millis ( 500 ) ,
93- target_delay : Duration :: from_millis ( 250 ) ,
94- } ;
86+ lazy_static ! {
87+ /// The default configuration to use for uTP connections.
88+ pub static ref UTP_CONN_CFG : ConnectionConfig = ConnectionConfig { max_packet_size: 1024 , ..Default :: default ( ) } ;
89+ }
9590
9691/// A network-based action that the overlay may perform.
9792///
@@ -836,7 +831,7 @@ where
836831 tokio:: spawn ( async move {
837832 metrics. report_utp_active_inc ( UtpDirectionLabel :: Inbound ) ;
838833 let mut stream = match utp
839- . connect_with_cid ( cid. clone ( ) , UTP_CONN_CFG )
834+ . connect_with_cid ( cid. clone ( ) , * UTP_CONN_CFG )
840835 . await
841836 {
842837 Ok ( stream) => stream,
@@ -1109,7 +1104,7 @@ where
11091104 let metrics = Arc :: clone ( & self . metrics ) ;
11101105 tokio:: spawn ( async move {
11111106 metrics. report_utp_active_inc ( UtpDirectionLabel :: Outbound ) ;
1112- let stream = match utp. accept_with_cid ( cid. clone ( ) , UTP_CONN_CFG ) . await {
1107+ let stream = match utp. accept_with_cid ( cid. clone ( ) , * UTP_CONN_CFG ) . await {
11131108 Ok ( stream) => stream,
11141109 Err ( err) => {
11151110 metrics. report_utp_outcome (
@@ -1237,7 +1232,7 @@ where
12371232 // Wait for an incoming connection with the given CID. Then, read the data from the uTP
12381233 // stream.
12391234 metrics. report_utp_active_inc ( UtpDirectionLabel :: Inbound ) ;
1240- let mut stream = match utp. accept_with_cid ( cid. clone ( ) , UTP_CONN_CFG ) . await {
1235+ let mut stream = match utp. accept_with_cid ( cid. clone ( ) , * UTP_CONN_CFG ) . await {
12411236 Ok ( stream) => stream,
12421237 Err ( err) => {
12431238 metrics. report_utp_outcome (
@@ -1500,7 +1495,7 @@ where
15001495
15011496 tokio:: spawn ( async move {
15021497 metrics. report_utp_active_inc ( UtpDirectionLabel :: Outbound ) ;
1503- let stream = match utp. connect_with_cid ( cid. clone ( ) , UTP_CONN_CFG ) . await {
1498+ let stream = match utp. connect_with_cid ( cid. clone ( ) , * UTP_CONN_CFG ) . await {
15041499 Ok ( stream) => stream,
15051500 Err ( err) => {
15061501 metrics. report_utp_outcome (
0 commit comments