Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

chore: upgrade to libp2p 0.39 #472

Merged
merged 6 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: code review - rework
  • Loading branch information
CHr15F0x committed Aug 18, 2021
commit c7a79980bdcc0bd0b7f86dbf8fa95e46a0692be1
8 changes: 6 additions & 2 deletions bitswap/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ use crate::ledger::Message;
use core::future::Future;
use core::iter;
use core::pin::Pin;
use futures::io::{AsyncRead, AsyncWrite};
use futures::{
io::{AsyncRead, AsyncWrite},
AsyncWriteExt,
};
use libp2p_core::{upgrade, InboundUpgrade, OutboundUpgrade, UpgradeInfo};
use std::io;

Expand Down Expand Up @@ -71,7 +74,8 @@ where
fn upgrade_outbound(self, mut socket: TSocket, _info: Self::Info) -> Self::Future {
Box::pin(async move {
let bytes = self.to_bytes();
upgrade::write_length_prefixed(&mut socket, bytes).await
upgrade::write_length_prefixed(&mut socket, bytes).await?;
socket.close().await
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ impl<TRepoTypes: RepoTypes> Future for IpfsFuture<TRepoTypes> {
loop {
let inner = {
use futures::StreamExt;
let next = self.swarm.next();
let next = self.swarm.select_next_some();
futures::pin_mut!(next);
match next.poll(ctx) {
Poll::Ready(inner) => inner,
Expand All @@ -1382,7 +1382,7 @@ impl<TRepoTypes: RepoTypes> Future for IpfsFuture<TRepoTypes> {
// off the events from Ipfs and ... this looping goes on for a while.
done = false;
match inner {
Some(SwarmEvent::NewListenAddr { address, .. }) => {
SwarmEvent::NewListenAddr { address, .. } => {
self.complete_listening_address_adding(address);
}
_ => trace!("{:?}", inner),
Expand Down
22 changes: 3 additions & 19 deletions src/p2p/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,26 +217,10 @@ pub(crate) fn could_be_bound_from_ephemeral(

// Checks if two instances of multiaddr are equal comparing as many protocol segments as possible
pub(crate) fn eq_greedy(addr0: &Multiaddr, addr1: &Multiaddr) -> bool {
match (addr0.is_empty(), addr1.is_empty()) {
(true, true) => true,
(false, false) => {
let mut it1 = addr1.iter();

for i0 in addr0.iter() {
if let Some(i1) = it1.next() {
if i0 != i1 {
return false;
}
} else {
// All previous segments were equal
return true;
}
}

true
}
_ => false,
if addr0.is_empty() != addr1.is_empty() {
return false;
}
addr0.iter().zip(addr1.iter()).all(|(a, b)| a == b)
}

#[cfg(test)]
Expand Down