@@ -24,8 +24,11 @@ use crate::{
2424 ConnectionMetrics , OutboundPing , Preferences , TimedMessage , TimedMessages ,
2525} ;
2626
27+ /// Maximum amount of time the peer has to seed a message after idling.
2728pub const READ_TIMEOUT : Duration = Duration :: from_secs ( 60 ) ;
29+ /// The interval to send a new ping message.
2830pub const PING_INTERVAL : Duration = Duration :: from_secs ( 30 ) ;
31+ /// The initial TCP handshake timeout.
2932pub const TCP_TIMEOUT : Duration = Duration :: from_secs ( 2 ) ;
3033
3134/// Open or begin a connection to an inbound or outbound peer.
@@ -151,6 +154,7 @@ impl ConnectionExt for ConnectionConfig {
151154 }
152155}
153156
157+ /// Configurations for ending a connection due to inactivity.
154158#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
155159pub struct TimeoutParams {
156160 read : Option < Duration > ,
@@ -160,22 +164,27 @@ pub struct TimeoutParams {
160164}
161165
162166impl TimeoutParams {
167+ /// Construct new timeout parameters
163168 pub fn new ( ) -> Self {
164169 Self :: default ( )
165170 }
166171
172+ /// Set the time a peer has until they have must sent a message.
167173 pub fn read_timeout ( & mut self , timeout : Duration ) {
168174 self . read = Some ( timeout)
169175 }
170-
176+
177+ /// Maximum amount of time it should take to write a message.
171178 pub fn write_timeout ( & mut self , timeout : Duration ) {
172179 self . write = Some ( timeout)
173180 }
174181
182+ /// The initial TCP handshake timeout.
175183 pub fn tcp_handshake_timeout ( & mut self , timeout : Duration ) {
176184 self . tcp = timeout;
177185 }
178186
187+ /// How often is this peer pinged for activity
179188 pub fn ping_interval ( & mut self , every : Duration ) {
180189 self . ping_interval = every
181190 }
0 commit comments