@@ -26,15 +26,14 @@ use futures::future;
26
26
use futures:: future:: { BoxFuture , FutureExt } ;
27
27
use instant:: Instant ;
28
28
use libp2p_core:: multiaddr:: Multiaddr ;
29
- use libp2p_core:: upgrade:: { DeniedUpgrade , NegotiationError , UpgradeError } ;
29
+ use libp2p_core:: upgrade:: DeniedUpgrade ;
30
30
use libp2p_core:: ConnectedPoint ;
31
31
use libp2p_swarm:: handler:: {
32
32
ConnectionEvent , DialUpgradeError , FullyNegotiatedInbound , FullyNegotiatedOutbound ,
33
33
ListenUpgradeError ,
34
34
} ;
35
35
use libp2p_swarm:: {
36
- ConnectionHandler , ConnectionHandlerEvent , ConnectionHandlerUpgrErr , KeepAlive ,
37
- SubstreamProtocol ,
36
+ ConnectionHandler , ConnectionHandlerEvent , KeepAlive , StreamUpgradeError , SubstreamProtocol ,
38
37
} ;
39
38
use std:: collections:: VecDeque ;
40
39
use std:: fmt;
@@ -82,11 +81,11 @@ pub enum Event {
82
81
remote_addr : Multiaddr ,
83
82
} ,
84
83
InboundNegotiationFailed {
85
- error : ConnectionHandlerUpgrErr < void:: Void > ,
84
+ error : StreamUpgradeError < void:: Void > ,
86
85
} ,
87
86
InboundConnectNegotiated ( Vec < Multiaddr > ) ,
88
87
OutboundNegotiationFailed {
89
- error : ConnectionHandlerUpgrErr < void:: Void > ,
88
+ error : StreamUpgradeError < void:: Void > ,
90
89
} ,
91
90
OutboundConnectNegotiated {
92
91
remote_addrs : Vec < Multiaddr > ,
@@ -127,7 +126,7 @@ pub struct Handler {
127
126
endpoint : ConnectedPoint ,
128
127
/// A pending fatal error that results in the connection being closed.
129
128
pending_error : Option <
130
- ConnectionHandlerUpgrErr <
129
+ StreamUpgradeError <
131
130
Either < protocol:: inbound:: UpgradeError , protocol:: outbound:: UpgradeError > ,
132
131
> ,
133
132
> ,
@@ -212,12 +211,10 @@ impl Handler {
212
211
<Self as ConnectionHandler >:: InboundProtocol ,
213
212
> ,
214
213
) {
215
- self . pending_error = Some ( ConnectionHandlerUpgrErr :: Upgrade ( UpgradeError :: Apply (
216
- match error {
217
- Either :: Left ( e) => Either :: Left ( e) ,
218
- Either :: Right ( v) => void:: unreachable ( v) ,
219
- } ,
220
- ) ) ) ;
214
+ self . pending_error = Some ( StreamUpgradeError :: Apply ( match error {
215
+ Either :: Left ( e) => Either :: Left ( e) ,
216
+ Either :: Right ( v) => void:: unreachable ( v) ,
217
+ } ) ) ;
221
218
}
222
219
223
220
fn on_dial_upgrade_error (
@@ -230,29 +227,27 @@ impl Handler {
230
227
self . keep_alive = KeepAlive :: No ;
231
228
232
229
match error {
233
- ConnectionHandlerUpgrErr :: Timeout => {
230
+ StreamUpgradeError :: Timeout => {
234
231
self . queued_events . push_back ( ConnectionHandlerEvent :: Custom (
235
232
Event :: OutboundNegotiationFailed {
236
- error : ConnectionHandlerUpgrErr :: Timeout ,
233
+ error : StreamUpgradeError :: Timeout ,
237
234
} ,
238
235
) ) ;
239
236
}
240
- ConnectionHandlerUpgrErr :: Upgrade ( UpgradeError :: Select ( NegotiationError :: Failed ) ) => {
237
+ StreamUpgradeError :: NegotiationFailed => {
241
238
// The remote merely doesn't support the DCUtR protocol.
242
239
// This is no reason to close the connection, which may
243
240
// successfully communicate with other protocols already.
244
241
self . queued_events . push_back ( ConnectionHandlerEvent :: Custom (
245
242
Event :: OutboundNegotiationFailed {
246
- error : ConnectionHandlerUpgrErr :: Upgrade ( UpgradeError :: Select (
247
- NegotiationError :: Failed ,
248
- ) ) ,
243
+ error : StreamUpgradeError :: NegotiationFailed ,
249
244
} ,
250
245
) ) ;
251
246
}
252
247
_ => {
253
248
// Anything else is considered a fatal error or misbehaviour of
254
249
// the remote peer and results in closing the connection.
255
- self . pending_error = Some ( error. map_upgrade_err ( |e| e . map_err ( Either :: Right ) ) ) ;
250
+ self . pending_error = Some ( error. map_upgrade_err ( Either :: Right ) ) ;
256
251
}
257
252
}
258
253
}
@@ -261,7 +256,7 @@ impl Handler {
261
256
impl ConnectionHandler for Handler {
262
257
type InEvent = Command ;
263
258
type OutEvent = Event ;
264
- type Error = ConnectionHandlerUpgrErr <
259
+ type Error = StreamUpgradeError <
265
260
Either < protocol:: inbound:: UpgradeError , protocol:: outbound:: UpgradeError > ,
266
261
> ;
267
262
type InboundProtocol = Either < protocol:: inbound:: Upgrade , DeniedUpgrade > ;
@@ -352,9 +347,9 @@ impl ConnectionHandler for Handler {
352
347
) ) ;
353
348
}
354
349
Err ( e) => {
355
- return Poll :: Ready ( ConnectionHandlerEvent :: Close (
356
- ConnectionHandlerUpgrErr :: Upgrade ( UpgradeError :: Apply ( Either :: Left ( e) ) ) ,
357
- ) )
350
+ return Poll :: Ready ( ConnectionHandlerEvent :: Close ( StreamUpgradeError :: Apply (
351
+ Either :: Left ( e) ,
352
+ ) ) )
358
353
}
359
354
}
360
355
}
0 commit comments