@@ -70,7 +70,7 @@ pub enum Error {
70
70
71
71
pub struct Behaviour {
72
72
/// Queue of actions to return when polled.
73
- queued_events : VecDeque < ToSwarm < Event , Either < handler:: relayed:: Command , Either < Void , Void > > > > ,
73
+ queued_events : VecDeque < ToSwarm < Event , Either < handler:: relayed:: Command , Void > > > ,
74
74
75
75
/// All direct (non-relayed) connections.
76
76
direct_connections : HashMap < PeerId , HashSet < ConnectionId > > ,
@@ -233,10 +233,7 @@ impl Behaviour {
233
233
}
234
234
235
235
impl NetworkBehaviour for Behaviour {
236
- type ConnectionHandler = Either <
237
- handler:: relayed:: Handler ,
238
- Either < handler:: direct:: Handler , dummy:: ConnectionHandler > ,
239
- > ;
236
+ type ConnectionHandler = Either < handler:: relayed:: Handler , dummy:: ConnectionHandler > ;
240
237
type ToSwarm = Event ;
241
238
242
239
fn handle_established_inbound_connection (
@@ -262,7 +259,7 @@ impl NetworkBehaviour for Behaviour {
262
259
"state mismatch"
263
260
) ;
264
261
265
- Ok ( Either :: Right ( Either :: Right ( dummy:: ConnectionHandler ) ) )
262
+ Ok ( Either :: Right ( dummy:: ConnectionHandler ) )
266
263
}
267
264
268
265
fn handle_established_outbound_connection (
@@ -293,12 +290,19 @@ impl NetworkBehaviour for Behaviour {
293
290
) ;
294
291
}
295
292
296
- return Ok ( Either :: Right ( Either :: Left (
297
- handler:: direct:: Handler :: default ( ) ,
298
- ) ) ) ;
293
+ self . queued_events . extend ( [
294
+ ToSwarm :: NotifyHandler {
295
+ peer_id : peer,
296
+ handler : NotifyHandler :: One ( relayed_connection_id) ,
297
+ event : Either :: Left ( handler:: relayed:: Command :: UpgradeFinishedDontKeepAlive ) ,
298
+ } ,
299
+ ToSwarm :: GenerateEvent ( Event :: DirectConnectionUpgradeSucceeded {
300
+ remote_peer_id : peer,
301
+ } ) ,
302
+ ] ) ;
299
303
}
300
304
301
- Ok ( Either :: Right ( Either :: Right ( dummy:: ConnectionHandler ) ) )
305
+ Ok ( Either :: Right ( dummy:: ConnectionHandler ) )
302
306
}
303
307
304
308
fn on_connection_handler_event (
@@ -383,21 +387,7 @@ impl NetworkBehaviour for Behaviour {
383
387
. or_default ( ) += 1 ;
384
388
self . queued_events . push_back ( ToSwarm :: Dial { opts } ) ;
385
389
}
386
- Either :: Right ( Either :: Left ( handler:: direct:: Event :: DirectConnectionEstablished ) ) => {
387
- self . queued_events . extend ( [
388
- ToSwarm :: NotifyHandler {
389
- peer_id : event_source,
390
- handler : NotifyHandler :: One ( relayed_connection_id) ,
391
- event : Either :: Left (
392
- handler:: relayed:: Command :: UpgradeFinishedDontKeepAlive ,
393
- ) ,
394
- } ,
395
- ToSwarm :: GenerateEvent ( Event :: DirectConnectionUpgradeSucceeded {
396
- remote_peer_id : event_source,
397
- } ) ,
398
- ] ) ;
399
- }
400
- Either :: Right ( Either :: Right ( never) ) => void:: unreachable ( never) ,
390
+ Either :: Right ( never) => void:: unreachable ( never) ,
401
391
} ;
402
392
}
403
393
0 commit comments