This repository was archived by the owner on Oct 23, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +11
-23
lines changed Expand file tree Collapse file tree 3 files changed +11
-23
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,10 @@ use crate::ledger::Message;
8
8
use core:: future:: Future ;
9
9
use core:: iter;
10
10
use core:: pin:: Pin ;
11
- use futures:: io:: { AsyncRead , AsyncWrite } ;
11
+ use futures:: {
12
+ io:: { AsyncRead , AsyncWrite } ,
13
+ AsyncWriteExt ,
14
+ } ;
12
15
use libp2p_core:: { upgrade, InboundUpgrade , OutboundUpgrade , UpgradeInfo } ;
13
16
use std:: io;
14
17
71
74
fn upgrade_outbound ( self , mut socket : TSocket , _info : Self :: Info ) -> Self :: Future {
72
75
Box :: pin ( async move {
73
76
let bytes = self . to_bytes ( ) ;
74
- upgrade:: write_length_prefixed ( & mut socket, bytes) . await
77
+ upgrade:: write_length_prefixed ( & mut socket, bytes) . await ?;
78
+ socket. close ( ) . await
75
79
} )
76
80
}
77
81
}
Original file line number Diff line number Diff line change @@ -1369,7 +1369,7 @@ impl<TRepoTypes: RepoTypes> Future for IpfsFuture<TRepoTypes> {
1369
1369
loop {
1370
1370
let inner = {
1371
1371
use futures:: StreamExt ;
1372
- let next = self . swarm . next ( ) ;
1372
+ let next = self . swarm . select_next_some ( ) ;
1373
1373
futures:: pin_mut!( next) ;
1374
1374
match next. poll ( ctx) {
1375
1375
Poll :: Ready ( inner) => inner,
@@ -1382,7 +1382,7 @@ impl<TRepoTypes: RepoTypes> Future for IpfsFuture<TRepoTypes> {
1382
1382
// off the events from Ipfs and ... this looping goes on for a while.
1383
1383
done = false ;
1384
1384
match inner {
1385
- Some ( SwarmEvent :: NewListenAddr { address, .. } ) => {
1385
+ SwarmEvent :: NewListenAddr { address, .. } => {
1386
1386
self . complete_listening_address_adding ( address) ;
1387
1387
}
1388
1388
_ => trace ! ( "{:?}" , inner) ,
Original file line number Diff line number Diff line change @@ -217,26 +217,10 @@ pub(crate) fn could_be_bound_from_ephemeral(
217
217
218
218
// Checks if two instances of multiaddr are equal comparing as many protocol segments as possible
219
219
pub ( crate ) fn eq_greedy ( addr0 : & Multiaddr , addr1 : & Multiaddr ) -> bool {
220
- match ( addr0. is_empty ( ) , addr1. is_empty ( ) ) {
221
- ( true , true ) => true ,
222
- ( false , false ) => {
223
- let mut it1 = addr1. iter ( ) ;
224
-
225
- for i0 in addr0. iter ( ) {
226
- if let Some ( i1) = it1. next ( ) {
227
- if i0 != i1 {
228
- return false ;
229
- }
230
- } else {
231
- // All previous segments were equal
232
- return true ;
233
- }
234
- }
235
-
236
- true
237
- }
238
- _ => false ,
220
+ if addr0. is_empty ( ) != addr1. is_empty ( ) {
221
+ return false ;
239
222
}
223
+ addr0. iter ( ) . zip ( addr1. iter ( ) ) . all ( |( a, b) | a == b)
240
224
}
241
225
242
226
#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments