Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e926778

Browse files
committed
use patch libp2p-yamux 0.41.1 and release 0.25.1
1 parent 9099af3 commit e926778

File tree

5 files changed

+40
-12
lines changed

5 files changed

+40
-12
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ members = [".", "cli", "harness"]
33

44
[package]
55
name = "ipfs-embed"
6-
version = "0.25.0"
6+
version = "0.25.1"
77
authors = ["David Craven <[email protected]>", "Roland Kuhn <[email protected]>"]
88
edition = "2018"
99
license = "MIT OR Apache-2.0"

harness/tests/netsim.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn run(bin: &str, args: impl IntoIterator<Item = &'static str>) -> anyhow::Resul
4141
fn netsim_bitswap() -> anyhow::Result<()> {
4242
run(
4343
"bitswap",
44-
["--enable-mdns", "--tree-depth=2", "--tree-width=4"],
44+
["--enable-mdns", "--tree-depth=2", "--tree-width=10"],
4545
)
4646
}
4747

@@ -54,7 +54,7 @@ fn netsim_bitswap_no_reuse() -> anyhow::Result<()> {
5454
"--enable-mdns",
5555
"--tree-depth=2",
5656
"--disable-port-reuse",
57-
"--tree-width=4",
57+
"--tree-width=10",
5858
],
5959
)
6060
}

src/net/peer_info.rs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ use fnv::FnvHashMap;
33
use libp2p::{
44
core::ConnectedPoint, multiaddr::Protocol, swarm::DialError, Multiaddr, TransportError,
55
};
6-
use std::{borrow::Cow, cmp::Ordering, collections::VecDeque, fmt::Write, time::Duration};
6+
use std::{
7+
borrow::Cow, cmp::Ordering, collections::VecDeque, error::Error, fmt::Write, io, time::Duration,
8+
};
79

810
#[derive(Clone, Debug, Default, Eq, PartialEq)]
911
pub struct PeerInfo {
@@ -263,7 +265,7 @@ pub struct ConnectionFailure {
263265
debug: String,
264266
}
265267

266-
#[derive(Debug, Clone, PartialEq, Eq)]
268+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
267269
pub enum ConnectionFailureKind {
268270
DialError,
269271
PeerDisconnected,
@@ -287,12 +289,12 @@ impl ConnectionFailure {
287289
DialError::Transport(e) => {
288290
if e.len() == 1 {
289291
// this should always be the case since we only get here for validation dials
290-
format!("transport error: {}", e[0].1)
292+
format!("transport error: {}", D(&e[0].1))
291293
} else {
292294
let mut s = "transport errors:".to_owned();
293295
for (addr, err) in e {
294296
s.push('\n');
295-
let _ = write!(&mut s, "{} {}", without_peer(addr), err);
297+
let _ = write!(&mut s, "{} {}", without_peer(addr), D(err));
296298
}
297299
s
298300
}
@@ -313,7 +315,7 @@ impl ConnectionFailure {
313315
kind: ConnectionFailureKind::DialError,
314316
addr: without_peer(&addr).into_owned(),
315317
time: Utc::now(),
316-
display: format!("transport error: {}", error),
318+
display: format!("transport error: {}", D(error)),
317319
debug: format!("{:?}", error),
318320
}
319321
}
@@ -338,6 +340,10 @@ impl ConnectionFailure {
338340
}
339341
}
340342

343+
pub fn kind(&self) -> ConnectionFailureKind {
344+
self.kind
345+
}
346+
341347
pub fn addr(&self) -> &Multiaddr {
342348
&self.addr
343349
}
@@ -354,3 +360,15 @@ impl ConnectionFailure {
354360
self.debug.as_str()
355361
}
356362
}
363+
364+
struct D<'a>(&'a TransportError<io::Error>);
365+
366+
impl<'a> std::fmt::Display for D<'a> {
367+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
368+
write!(f, "{}", self.0)?;
369+
if let Some(cause) = self.0.source() {
370+
write!(f, "{}", cause)?;
371+
}
372+
Ok(())
373+
}
374+
}

src/net/tests.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::{address_handler::IntoAddressHandler, *};
2-
use crate::net::peers::AddressBook;
2+
use crate::net::{peer_info::ConnectionFailureKind, peers::AddressBook};
33
use async_executor::LocalExecutor;
44
use futures::{future::ready, stream::StreamExt};
55
use libp2p::{
@@ -111,6 +111,16 @@ fn test_dial_basic() {
111111
)
112112
);
113113
assert_eq!(book.peers().into_iter().next(), Some(peer_a));
114+
let failure = book
115+
.info(&peer_a)
116+
.unwrap()
117+
.recent_failures()
118+
.next()
119+
.cloned()
120+
.unwrap();
121+
assert_eq!(failure.kind(), ConnectionFailureKind::DialError);
122+
assert_eq!(failure.addr(), &addr_2);
123+
assert_eq!(failure.display(), "transport error: my other error");
114124
assert_eq!(dials(&mut book), vec![]);
115125

116126
assert_eq!(

0 commit comments

Comments
 (0)