Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
31 changes: 28 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ x25519-dalek = "2.0.0"
x509-parser = "0.16.0"
yasna = "0.5.0"
zeroize = "1.8.1"
nohash-hasher = "0.2.0"
static_assertions = "1.1.0"
yamux = "0.13.4"

# Exposed dependencies. Breaking changes to these are breaking changes to us.
[dependencies.rustls]
Expand Down
72 changes: 71 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub enum ParseError {
InvalidData,
}

#[derive(Debug, thiserror::Error, PartialEq)]
#[derive(Debug, thiserror::Error)]
pub enum SubstreamError {
#[error("Connection closed")]
ConnectionClosed,
Expand All @@ -202,6 +202,76 @@ pub enum SubstreamError {
NegotiationError(#[from] NegotiationError),
}

// Libp2p yamux does not implement PartialEq for ConnectionError.
impl PartialEq for SubstreamError {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::ConnectionClosed, Self::ConnectionClosed) => true,
(Self::ChannelClogged, Self::ChannelClogged) => true,
(Self::PeerDoesNotExist(lhs), Self::PeerDoesNotExist(rhs)) => lhs == rhs,
(Self::IoError(lhs), Self::IoError(rhs)) => lhs == rhs,
(Self::YamuxError(lhs, lhs_1), Self::YamuxError(rhs, rhs_1)) => {
if lhs_1 != rhs_1 {
return false;
}

match (lhs, rhs) {
(
crate::yamux::ConnectionError::Io(lhs),
crate::yamux::ConnectionError::Io(rhs),
) => lhs.kind() == rhs.kind(),
(
crate::yamux::ConnectionError::Decode(lhs),
crate::yamux::ConnectionError::Decode(rhs),
) => match (lhs, rhs) {
(
crate::yamux::FrameDecodeError::Io(lhs),
crate::yamux::FrameDecodeError::Io(rhs),
) => lhs.kind() == rhs.kind(),
(
crate::yamux::FrameDecodeError::FrameTooLarge(lhs),
crate::yamux::FrameDecodeError::FrameTooLarge(rhs),
) => lhs == rhs,
(
crate::yamux::FrameDecodeError::Header(lhs),
crate::yamux::FrameDecodeError::Header(rhs),
) => match (lhs, rhs) {
(
crate::yamux::HeaderDecodeError::Version(lhs),
crate::yamux::HeaderDecodeError::Version(rhs),
) => lhs == rhs,
(
crate::yamux::HeaderDecodeError::Type(lhs),
crate::yamux::HeaderDecodeError::Type(rhs),
) => lhs == rhs,
_ => false,
},
_ => false,
},
(
crate::yamux::ConnectionError::NoMoreStreamIds,
crate::yamux::ConnectionError::NoMoreStreamIds,
) => true,
(
crate::yamux::ConnectionError::Closed,
crate::yamux::ConnectionError::Closed,
) => true,
(
crate::yamux::ConnectionError::TooManyStreams,
crate::yamux::ConnectionError::TooManyStreams,
) => true,
_ => false,
}
}

(Self::ReadFailure(lhs), Self::ReadFailure(rhs)) => lhs == rhs,
(Self::WriteFailure(lhs), Self::WriteFailure(rhs)) => lhs == rhs,
(Self::NegotiationError(lhs), Self::NegotiationError(rhs)) => lhs == rhs,
_ => false,
}
}
}

/// Error during the negotiation phase.
#[derive(Debug, thiserror::Error)]
pub enum NegotiationError {
Expand Down
111 changes: 0 additions & 111 deletions src/yamux/chunks.rs

This file was deleted.

Loading
Loading