mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-17 20:11:22 +00:00
feat(swarm): deprecate NegotiatedSubstream
in favor of Stream
This patch tackles two things at once that are fairly intertwined: 1. There is no such thing as a "substream" in libp2p, the spec and other implementations only talk about "streams". We fix this by deprecating `NegotiatedSubstream`. 2. Previously, `NegotiatedSubstream` was a type alias that pointed to a type from `multistream-select`, effectively leaking the version of `multistream-select` to all dependencies of `libp2p-swarm`. We fix this by introducing a `Stream` newtype. Resolves: #3759. Related: #3748. Pull-Request: #3912.
This commit is contained in:
@ -27,7 +27,7 @@ use libp2p_swarm::handler::{
|
||||
ConnectionEvent, DialUpgradeError, FullyNegotiatedInbound, FullyNegotiatedOutbound,
|
||||
};
|
||||
use libp2p_swarm::{
|
||||
ConnectionHandler, ConnectionHandlerEvent, KeepAlive, NegotiatedSubstream, StreamProtocol,
|
||||
ConnectionHandler, ConnectionHandlerEvent, KeepAlive, Stream, StreamProtocol,
|
||||
StreamUpgradeError, SubstreamProtocol,
|
||||
};
|
||||
use std::collections::VecDeque;
|
||||
@ -390,15 +390,15 @@ impl ConnectionHandler for Handler {
|
||||
}
|
||||
}
|
||||
|
||||
type PingFuture = BoxFuture<'static, Result<(NegotiatedSubstream, Duration), io::Error>>;
|
||||
type PongFuture = BoxFuture<'static, Result<NegotiatedSubstream, io::Error>>;
|
||||
type PingFuture = BoxFuture<'static, Result<(Stream, Duration), io::Error>>;
|
||||
type PongFuture = BoxFuture<'static, Result<Stream, io::Error>>;
|
||||
|
||||
/// The current state w.r.t. outbound pings.
|
||||
enum OutboundState {
|
||||
/// A new substream is being negotiated for the ping protocol.
|
||||
OpenStream,
|
||||
/// The substream is idle, waiting to send the next ping.
|
||||
Idle(NegotiatedSubstream),
|
||||
Idle(Stream),
|
||||
/// A ping is being sent and the response awaited.
|
||||
Ping(PingFuture),
|
||||
}
|
||||
|
Reference in New Issue
Block a user