1
- use crate :: p2p:: { addr :: eq_greedy , MultiaddrWithPeerId , MultiaddrWithoutPeerId } ;
1
+ use crate :: p2p:: { MultiaddrWithPeerId , MultiaddrWithoutPeerId } ;
2
2
use crate :: subscription:: { SubscriptionFuture , SubscriptionRegistry } ;
3
3
use core:: task:: { Context , Poll } ;
4
4
use libp2p:: core:: { connection:: ConnectionId , ConnectedPoint , Multiaddr , PeerId } ;
@@ -106,21 +106,17 @@ impl SwarmApi {
106
106
. connect_registry
107
107
. create_subscription ( addr. clone ( ) . into ( ) , None ) ;
108
108
109
- // libp2p currently doesn't support dialing with the P2p protocol, so only consider the
110
- // "bare" Multiaddr
111
- let MultiaddrWithPeerId { multiaddr, peer_id } = addr;
112
-
113
109
self . events . push_back ( NetworkBehaviourAction :: DialPeer {
114
- peer_id,
110
+ peer_id : addr . peer_id ,
115
111
// rationale: this is sort of explicit command, perhaps the old address is no longer
116
112
// valid. Always would be even better but it's bugged at the moment.
117
113
condition : DialPeerCondition :: NotDialing ,
118
114
} ) ;
119
115
120
116
self . pending_addresses
121
- . entry ( peer_id)
117
+ . entry ( addr . peer_id )
122
118
. or_insert_with ( || Vec :: with_capacity ( 1 ) )
123
- . push ( multiaddr . into ( ) ) ;
119
+ . push ( addr . into ( ) ) ;
124
120
125
121
Some ( subscription)
126
122
}
@@ -194,7 +190,7 @@ impl NetworkBehaviour for SwarmApi {
194
190
match self . pending_connections . entry ( * peer_id) {
195
191
Entry :: Occupied ( mut oe) => {
196
192
let addresses = oe. get_mut ( ) ;
197
- let just_connected = addresses. iter ( ) . position ( |x| eq_greedy ( x , address) ) ;
193
+ let just_connected = addresses. iter ( ) . position ( |a| a == address) ;
198
194
if let Some ( just_connected) = just_connected {
199
195
addresses. swap_remove ( just_connected) ;
200
196
if addresses. is_empty ( ) {
@@ -235,9 +231,8 @@ impl NetworkBehaviour for SwarmApi {
235
231
) ;
236
232
237
233
for addr in all_subs {
238
- let addr = MultiaddrWithoutPeerId :: try_from ( addr)
239
- . expect ( "peerid has been stripped earlier" )
240
- . with ( * peer_id) ;
234
+ let addr = MultiaddrWithPeerId :: try_from ( addr)
235
+ . expect ( "dialed address contains peerid in libp2p 0.38" ) ;
241
236
242
237
// fail the other than already connected subscriptions in
243
238
// inject_connection_established. while the whole swarmapi is quite unclear on the
@@ -335,9 +330,8 @@ impl NetworkBehaviour for SwarmApi {
335
330
) ;
336
331
337
332
for addr in failed {
338
- let addr = MultiaddrWithoutPeerId :: try_from ( addr)
339
- . expect ( "peerid has been stripped earlier" )
340
- . with ( * peer_id) ;
333
+ let addr = MultiaddrWithPeerId :: try_from ( addr)
334
+ . expect ( "dialed address contains peerid in libp2p 0.38" ) ;
341
335
342
336
self . connect_registry
343
337
. finish_subscription ( addr. into ( ) , Err ( "disconnected" . into ( ) ) ) ;
@@ -361,9 +355,8 @@ impl NetworkBehaviour for SwarmApi {
361
355
// this should not be executed once, but probably will be in case unsupported addresses or something
362
356
// surprising happens.
363
357
for failed in self . pending_connections . remove ( peer_id) . unwrap_or_default ( ) {
364
- let addr = MultiaddrWithoutPeerId :: try_from ( failed)
365
- . expect ( "peerid has been stripped earlier" )
366
- . with ( * peer_id) ;
358
+ let addr = MultiaddrWithPeerId :: try_from ( failed)
359
+ . expect ( "dialed address contains peerid in libp2p 0.38" ) ;
367
360
368
361
self . connect_registry
369
362
. finish_subscription ( addr. into ( ) , Err ( "addresses exhausted" . into ( ) ) ) ;
@@ -382,7 +375,7 @@ impl NetworkBehaviour for SwarmApi {
382
375
match self . pending_connections . entry ( * peer_id) {
383
376
Entry :: Occupied ( mut oe) => {
384
377
let addresses = oe. get_mut ( ) ;
385
- let pos = addresses. iter ( ) . position ( |a| eq_greedy ( a , addr) ) ;
378
+ let pos = addresses. iter ( ) . position ( |a| a == addr) ;
386
379
387
380
if let Some ( pos) = pos {
388
381
addresses. swap_remove ( pos) ;
0 commit comments