diff --git a/protocols/gossipsub/src/error.rs b/protocols/gossipsub/src/error.rs index aa04144ff79..61ef13bd248 100644 --- a/protocols/gossipsub/src/error.rs +++ b/protocols/gossipsub/src/error.rs @@ -30,16 +30,10 @@ pub type PublishError = crate::error_priv::PublishError; )] pub type SubscriptionError = crate::error_priv::SubscriptionError; -#[deprecated( - since = "0.44.0", - note = "Use re-exports that omit `Gossipsub` prefix, i.e. `libp2p::gossipsub::HandlerError" -)] +#[deprecated(note = "This error will no longer be emitted")] pub type GossipsubHandlerError = crate::error_priv::HandlerError; -#[deprecated( - since = "0.44.0", - note = "Use `libp2p::gossipsub::HandlerError` instead, as the `error` module will become crate-private in the future." -)] +#[deprecated(note = "This error will no longer be emitted")] pub type HandlerError = crate::error_priv::HandlerError; #[deprecated( diff --git a/protocols/gossipsub/src/error_priv.rs b/protocols/gossipsub/src/error_priv.rs index cbdd7540adf..04cc72028cd 100644 --- a/protocols/gossipsub/src/error_priv.rs +++ b/protocols/gossipsub/src/error_priv.rs @@ -89,19 +89,14 @@ impl From for PublishError { /// Errors that can occur in the protocols handler. #[derive(Debug, Error)] pub enum HandlerError { - #[deprecated(note = "This error will no longer be emitted")] #[error("The maximum number of inbound substreams created has been exceeded.")] MaxInboundSubstreams, - #[deprecated(note = "This error will no longer be emitted")] #[error("The maximum number of outbound substreams created has been exceeded.")] MaxOutboundSubstreams, - #[deprecated(note = "This error will no longer be emitted")] #[error("The message exceeds the maximum transmission size.")] MaxTransmissionSize, - #[deprecated(note = "This error will no longer be emitted")] #[error("Protocol negotiation timeout.")] NegotiationTimeout, - #[deprecated(note = "This error will no longer be emitted")] #[error("Protocol negotiation failed.")] NegotiationProtocolError(ProtocolError), #[error("Failed to encode or decode")] @@ -139,12 +134,6 @@ impl std::fmt::Display for ValidationError { impl std::error::Error for ValidationError {} -impl From for HandlerError { - fn from(error: std::io::Error) -> HandlerError { - HandlerError::Codec(quick_protobuf_codec::Error::from(error)) - } -} - impl From for PublishError { fn from(error: std::io::Error) -> PublishError { PublishError::TransformFailed(error) diff --git a/protocols/gossipsub/src/handler.rs b/protocols/gossipsub/src/handler.rs index dce053be9d6..79bd9df9599 100644 --- a/protocols/gossipsub/src/handler.rs +++ b/protocols/gossipsub/src/handler.rs @@ -21,7 +21,7 @@ use crate::protocol::{GossipsubCodec, ProtocolConfig}; use crate::rpc_proto::proto; use crate::types::{PeerKind, RawMessage, Rpc}; -use crate::{HandlerError, ValidationError}; +use crate::ValidationError; use asynchronous_codec::Framed; use futures::prelude::*; use futures::StreamExt; @@ -238,7 +238,7 @@ impl Handler { impl ConnectionHandler for Handler { type InEvent = HandlerIn; type OutEvent = HandlerEvent; - type Error = HandlerError; + type Error = crate::error_priv::HandlerError; // TODO: Replace this with `Void`. type InboundOpenInfo = (); type InboundProtocol = ProtocolConfig; type OutboundOpenInfo = proto::RPC; diff --git a/protocols/gossipsub/src/lib.rs b/protocols/gossipsub/src/lib.rs index 222a2f34f93..4a1d63d93da 100644 --- a/protocols/gossipsub/src/lib.rs +++ b/protocols/gossipsub/src/lib.rs @@ -158,9 +158,12 @@ mod types; mod rpc_proto; +#[deprecated(note = "This error will no longer be emitted")] +pub type HandlerError = error_priv::HandlerError; + pub use self::behaviour::{Behaviour, Event, MessageAuthenticity}; pub use self::config::{Config, ConfigBuilder, ValidationMode, Version}; -pub use self::error_priv::{HandlerError, PublishError, SubscriptionError, ValidationError}; +pub use self::error_priv::{PublishError, SubscriptionError, ValidationError}; pub use self::peer_score::{ score_parameter_decay, score_parameter_decay_with_base, PeerScoreParams, PeerScoreThresholds, TopicScoreParams, diff --git a/protocols/gossipsub/src/protocol.rs b/protocols/gossipsub/src/protocol.rs index 15824db443a..3a2de0f5fc2 100644 --- a/protocols/gossipsub/src/protocol.rs +++ b/protocols/gossipsub/src/protocol.rs @@ -24,8 +24,8 @@ use crate::topic::TopicHash; use crate::types::{ ControlAction, MessageId, PeerInfo, PeerKind, RawMessage, Rpc, Subscription, SubscriptionAction, }; +use crate::ValidationError; use crate::{rpc_proto::proto, Config}; -use crate::{HandlerError, ValidationError}; use asynchronous_codec::{Decoder, Encoder, Framed}; use byteorder::{BigEndian, ByteOrder}; use bytes::BytesMut; @@ -273,18 +273,18 @@ impl GossipsubCodec { impl Encoder for GossipsubCodec { type Item = proto::RPC; - type Error = HandlerError; + type Error = quick_protobuf_codec::Error; - fn encode(&mut self, item: Self::Item, dst: &mut BytesMut) -> Result<(), HandlerError> { - Ok(self.codec.encode(item, dst)?) + fn encode(&mut self, item: Self::Item, dst: &mut BytesMut) -> Result<(), Self::Error> { + self.codec.encode(item, dst) } } impl Decoder for GossipsubCodec { type Item = HandlerEvent; - type Error = HandlerError; + type Error = quick_protobuf_codec::Error; - fn decode(&mut self, src: &mut BytesMut) -> Result, HandlerError> { + fn decode(&mut self, src: &mut BytesMut) -> Result, Self::Error> { let rpc = match self.codec.decode(src)? { Some(p) => p, None => return Ok(None),