@@ -26,7 +26,7 @@ use crate::{
26
26
Connected , ConnectionError , ConnectionLimit , IncomingInfo , PendingConnectionError ,
27
27
PendingInboundConnectionError , PendingOutboundConnectionError ,
28
28
} ,
29
- transport:: { Transport , TransportError } ,
29
+ transport:: TransportError ,
30
30
ConnectedPoint , ConnectionHandler , Executor , IntoConnectionHandler , Multiaddr , PeerId ,
31
31
} ;
32
32
use concurrent_dial:: ConcurrentDial ;
@@ -79,9 +79,8 @@ impl ExecSwitch {
79
79
}
80
80
81
81
/// A connection `Pool` manages a set of connections for each peer.
82
- pub struct Pool < THandler , TTrans >
82
+ pub struct Pool < THandler >
83
83
where
84
- TTrans : Transport ,
85
84
THandler : IntoConnectionHandler ,
86
85
{
87
86
local_id : PeerId ,
@@ -124,10 +123,10 @@ where
124
123
125
124
/// Sender distributed to pending tasks for reporting events back
126
125
/// to the pool.
127
- pending_connection_events_tx : mpsc:: Sender < task:: PendingConnectionEvent < TTrans > > ,
126
+ pending_connection_events_tx : mpsc:: Sender < task:: PendingConnectionEvent > ,
128
127
129
128
/// Receiver for events reported from pending tasks.
130
- pending_connection_events_rx : mpsc:: Receiver < task:: PendingConnectionEvent < TTrans > > ,
129
+ pending_connection_events_rx : mpsc:: Receiver < task:: PendingConnectionEvent > ,
131
130
132
131
/// Sender distributed to established tasks for reporting events back
133
132
/// to the pool.
@@ -213,7 +212,7 @@ impl<THandler> PendingConnection<THandler> {
213
212
}
214
213
}
215
214
216
- impl < THandler : IntoConnectionHandler , TTrans : Transport > fmt:: Debug for Pool < THandler , TTrans > {
215
+ impl < THandler : IntoConnectionHandler > fmt:: Debug for Pool < THandler > {
217
216
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> Result < ( ) , fmt:: Error > {
218
217
f. debug_struct ( "Pool" )
219
218
. field ( "counters" , & self . counters )
@@ -223,10 +222,7 @@ impl<THandler: IntoConnectionHandler, TTrans: Transport> fmt::Debug for Pool<THa
223
222
224
223
/// Event that can happen on the `Pool`.
225
224
#[ derive( Debug ) ]
226
- pub enum PoolEvent < THandler : IntoConnectionHandler , TTrans >
227
- where
228
- TTrans : Transport ,
229
- {
225
+ pub enum PoolEvent < THandler : IntoConnectionHandler > {
230
226
/// A new connection has been established.
231
227
ConnectionEstablished {
232
228
id : ConnectionId ,
@@ -239,7 +235,7 @@ where
239
235
/// [`Some`] when the new connection is an outgoing connection.
240
236
/// Addresses are dialed in parallel. Contains the addresses and errors
241
237
/// of dial attempts that failed before the one successful dial.
242
- concurrent_dial_errors : Option < Vec < ( Multiaddr , TransportError < TTrans :: Error > ) > > ,
238
+ concurrent_dial_errors : Option < Vec < ( Multiaddr , TransportError < std :: io :: Error > ) > > ,
243
239
/// How long it took to establish this connection.
244
240
established_in : std:: time:: Duration ,
245
241
} ,
@@ -272,7 +268,7 @@ where
272
268
/// The ID of the failed connection.
273
269
id : ConnectionId ,
274
270
/// The error that occurred.
275
- error : PendingOutboundConnectionError < TTrans :: Error > ,
271
+ error : PendingOutboundConnectionError ,
276
272
/// The handler that was supposed to handle the connection.
277
273
handler : THandler ,
278
274
/// The (expected) peer of the failed connection.
@@ -288,7 +284,7 @@ where
288
284
/// Local connection address.
289
285
local_addr : Multiaddr ,
290
286
/// The error that occurred.
291
- error : PendingInboundConnectionError < TTrans :: Error > ,
287
+ error : PendingInboundConnectionError ,
292
288
/// The handler that was supposed to handle the connection.
293
289
handler : THandler ,
294
290
} ,
@@ -312,10 +308,9 @@ where
312
308
} ,
313
309
}
314
310
315
- impl < THandler , TTrans > Pool < THandler , TTrans >
311
+ impl < THandler > Pool < THandler >
316
312
where
317
313
THandler : IntoConnectionHandler ,
318
- TTrans : Transport ,
319
314
{
320
315
/// Creates a new empty `Pool`.
321
316
pub fn new ( local_id : PeerId , config : PoolConfig , limits : ConnectionLimits ) -> Self {
@@ -429,12 +424,9 @@ where
429
424
}
430
425
}
431
426
432
- impl < THandler , TTrans > Pool < THandler , TTrans >
427
+ impl < THandler > Pool < THandler >
433
428
where
434
429
THandler : IntoConnectionHandler ,
435
- TTrans : Transport + ' static ,
436
- TTrans :: Output : Send + ' static ,
437
- TTrans :: Error : Send + ' static ,
438
430
{
439
431
/// Adds a pending outgoing connection to the pool in the form of a `Future`
440
432
/// that establishes and negotiates the connection.
@@ -448,22 +440,15 @@ where
448
440
' static ,
449
441
(
450
442
Multiaddr ,
451
- Result <
452
- <TTrans as Transport >:: Output ,
453
- TransportError < <TTrans as Transport >:: Error > ,
454
- > ,
443
+ Result < ( PeerId , StreamMuxerBox ) , TransportError < std:: io:: Error > > ,
455
444
) ,
456
445
> ,
457
446
> ,
458
447
peer : Option < PeerId > ,
459
448
handler : THandler ,
460
449
role_override : Endpoint ,
461
450
dial_concurrency_factor_override : Option < NonZeroU8 > ,
462
- ) -> Result < ConnectionId , ( ConnectionLimit , THandler ) >
463
- where
464
- TTrans : Send ,
465
- TTrans :: Dial : Send + ' static ,
466
- {
451
+ ) -> Result < ConnectionId , ( ConnectionLimit , THandler ) > {
467
452
if let Err ( limit) = self . counters . check_max_pending_outgoing ( ) {
468
453
return Err ( ( limit, handler) ) ;
469
454
} ;
@@ -515,7 +500,7 @@ where
515
500
info : IncomingInfo < ' _ > ,
516
501
) -> Result < ConnectionId , ( ConnectionLimit , THandler ) >
517
502
where
518
- TFut : Future < Output = Result < TTrans :: Output , TTrans :: Error > > + Send + ' static ,
503
+ TFut : Future < Output = Result < ( PeerId , StreamMuxerBox ) , std :: io :: Error > > + Send + ' static ,
519
504
{
520
505
let endpoint = info. create_connected_point ( ) ;
521
506
@@ -552,9 +537,8 @@ where
552
537
}
553
538
554
539
/// Polls the connection pool for events.
555
- pub fn poll ( & mut self , cx : & mut Context < ' _ > ) -> Poll < PoolEvent < THandler , TTrans > >
540
+ pub fn poll ( & mut self , cx : & mut Context < ' _ > ) -> Poll < PoolEvent < THandler > >
556
541
where
557
- TTrans : Transport < Output = ( PeerId , StreamMuxerBox ) > ,
558
542
THandler : IntoConnectionHandler + ' static ,
559
543
THandler :: Handler : ConnectionHandler + Send ,
560
544
<THandler :: Handler as ConnectionHandler >:: OutboundOpenInfo : Send ,
@@ -677,7 +661,7 @@ where
677
661
) ,
678
662
} ;
679
663
680
- let error: Result < ( ) , PendingInboundConnectionError < _ > > = self
664
+ let error = self
681
665
. counters
682
666
// Check general established connection limit.
683
667
. check_max_established ( & endpoint)
0 commit comments