mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-19 04:51:22 +00:00
Deprecate StreamMuxer::is_remote_acknowledged (#1616)
This commit is contained in:
@ -230,14 +230,6 @@ where
|
|||||||
self.handler.inject_event(event);
|
self.handler.inject_event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if the remote has shown any sign of activity
|
|
||||||
/// since the connection has been established.
|
|
||||||
///
|
|
||||||
/// See also [`StreamMuxer::is_remote_acknowledged`].
|
|
||||||
pub fn is_remote_acknowledged(&self) -> bool {
|
|
||||||
self.muxing.is_remote_acknowledged()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Begins an orderly shutdown of the connection, returning a
|
/// Begins an orderly shutdown of the connection, returning a
|
||||||
/// `Future` that resolves when connection shutdown is complete.
|
/// `Future` that resolves when connection shutdown is complete.
|
||||||
pub fn close(self) -> Close<TMuxer> {
|
pub fn close(self) -> Close<TMuxer> {
|
||||||
|
@ -123,13 +123,6 @@ where
|
|||||||
self.outbound_substreams.push((user_data, raw));
|
self.outbound_substreams.push((user_data, raw));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if the remote has shown any sign of activity after the muxer has been open.
|
|
||||||
///
|
|
||||||
/// See `StreamMuxer::is_remote_acknowledged`.
|
|
||||||
pub fn is_remote_acknowledged(&self) -> bool {
|
|
||||||
self.inner.is_remote_acknowledged()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Destroys the node stream and returns all the pending outbound substreams, plus an object
|
/// Destroys the node stream and returns all the pending outbound substreams, plus an object
|
||||||
/// that signals the remote that we shut down the connection.
|
/// that signals the remote that we shut down the connection.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
@ -297,13 +297,6 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_remote_acknowledged(&self) -> bool {
|
|
||||||
match self {
|
|
||||||
EitherOutput::First(inner) => inner.is_remote_acknowledged(),
|
|
||||||
EitherOutput::Second(inner) => inner.is_remote_acknowledged()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn close(&self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
fn close(&self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||||
match self {
|
match self {
|
||||||
EitherOutput::First(inner) => inner.close(cx).map_err(|e| e.into()),
|
EitherOutput::First(inner) => inner.close(cx).map_err(|e| e.into()),
|
||||||
|
@ -64,8 +64,7 @@ mod singleton;
|
|||||||
///
|
///
|
||||||
/// The state of a muxer, as exposed by this API, is the following:
|
/// The state of a muxer, as exposed by this API, is the following:
|
||||||
///
|
///
|
||||||
/// - A connection to the remote. The `is_remote_acknowledged`, `flush_all` and `close` methods
|
/// - A connection to the remote. The `flush_all` and `close` methods operate on this.
|
||||||
/// operate on this.
|
|
||||||
/// - A list of substreams that are open. The `poll_inbound`, `poll_outbound`, `read_substream`,
|
/// - A list of substreams that are open. The `poll_inbound`, `poll_outbound`, `read_substream`,
|
||||||
/// `write_substream`, `flush_substream`, `shutdown_substream` and `destroy_substream` methods
|
/// `write_substream`, `flush_substream`, `shutdown_substream` and `destroy_substream` methods
|
||||||
/// allow controlling these entries.
|
/// allow controlling these entries.
|
||||||
@ -180,7 +179,10 @@ pub trait StreamMuxer {
|
|||||||
/// allowed to assume that the handshake has succeeded when it didn't in fact succeed. This
|
/// allowed to assume that the handshake has succeeded when it didn't in fact succeed. This
|
||||||
/// method can be called in order to determine whether the remote has accepted our handshake or
|
/// method can be called in order to determine whether the remote has accepted our handshake or
|
||||||
/// has potentially not received it yet.
|
/// has potentially not received it yet.
|
||||||
fn is_remote_acknowledged(&self) -> bool;
|
#[deprecated(note = "This method is unused and will be removed in the future")]
|
||||||
|
fn is_remote_acknowledged(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
/// Closes this `StreamMuxer`.
|
/// Closes this `StreamMuxer`.
|
||||||
///
|
///
|
||||||
@ -525,11 +527,6 @@ impl StreamMuxer for StreamMuxerBox {
|
|||||||
self.inner.close(cx)
|
self.inner.close(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn is_remote_acknowledged(&self) -> bool {
|
|
||||||
self.inner.is_remote_acknowledged()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn flush_all(&self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
fn flush_all(&self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||||
self.inner.flush_all(cx)
|
self.inner.flush_all(cx)
|
||||||
@ -631,11 +628,6 @@ where
|
|||||||
self.inner.close(cx).map_err(|e| e.into())
|
self.inner.close(cx).map_err(|e| e.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn is_remote_acknowledged(&self) -> bool {
|
|
||||||
self.inner.is_remote_acknowledged()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn flush_all(&self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
fn flush_all(&self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
|
||||||
self.inner.flush_all(cx).map_err(|e| e.into())
|
self.inner.flush_all(cx).map_err(|e| e.into())
|
||||||
|
@ -35,8 +35,6 @@ pub struct SingletonMuxer<TSocket> {
|
|||||||
substream_extracted: AtomicBool,
|
substream_extracted: AtomicBool,
|
||||||
/// Our local endpoint. Always the same value as was passed to `new`.
|
/// Our local endpoint. Always the same value as was passed to `new`.
|
||||||
endpoint: Endpoint,
|
endpoint: Endpoint,
|
||||||
/// If true, we have received data from the remote.
|
|
||||||
remote_acknowledged: AtomicBool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<TSocket> SingletonMuxer<TSocket> {
|
impl<TSocket> SingletonMuxer<TSocket> {
|
||||||
@ -49,7 +47,6 @@ impl<TSocket> SingletonMuxer<TSocket> {
|
|||||||
inner: Mutex::new(inner),
|
inner: Mutex::new(inner),
|
||||||
substream_extracted: AtomicBool::new(false),
|
substream_extracted: AtomicBool::new(false),
|
||||||
endpoint,
|
endpoint,
|
||||||
remote_acknowledged: AtomicBool::new(false),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,11 +98,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn read_substream(&self, cx: &mut Context, _: &mut Self::Substream, buf: &mut [u8]) -> Poll<Result<usize, io::Error>> {
|
fn read_substream(&self, cx: &mut Context, _: &mut Self::Substream, buf: &mut [u8]) -> Poll<Result<usize, io::Error>> {
|
||||||
let res = AsyncRead::poll_read(Pin::new(&mut *self.inner.lock()), cx, buf);
|
AsyncRead::poll_read(Pin::new(&mut *self.inner.lock()), cx, buf)
|
||||||
if let Poll::Ready(Ok(_)) = res {
|
|
||||||
self.remote_acknowledged.store(true, Ordering::Release);
|
|
||||||
}
|
|
||||||
res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_substream(&self, cx: &mut Context, _: &mut Self::Substream, buf: &[u8]) -> Poll<Result<usize, io::Error>> {
|
fn write_substream(&self, cx: &mut Context, _: &mut Self::Substream, buf: &[u8]) -> Poll<Result<usize, io::Error>> {
|
||||||
@ -123,10 +116,6 @@ where
|
|||||||
fn destroy_substream(&self, _: Self::Substream) {
|
fn destroy_substream(&self, _: Self::Substream) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_remote_acknowledged(&self) -> bool {
|
|
||||||
self.remote_acknowledged.load(Ordering::Acquire)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn close(&self, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
fn close(&self, cx: &mut Context) -> Poll<Result<(), io::Error>> {
|
||||||
// The `StreamMuxer` trait requires that `close()` implies `flush_all()`.
|
// The `StreamMuxer` trait requires that `close()` implies `flush_all()`.
|
||||||
self.flush_all(cx)
|
self.flush_all(cx)
|
||||||
|
@ -110,7 +110,6 @@ impl MplexConfig {
|
|||||||
to_wake: Mutex::new(Default::default()),
|
to_wake: Mutex::new(Default::default()),
|
||||||
}),
|
}),
|
||||||
is_shutdown: false,
|
is_shutdown: false,
|
||||||
is_acknowledged: false,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,8 +202,6 @@ struct MultiplexInner<C> {
|
|||||||
/// If true, the connection has been shut down. We need to be careful not to accidentally
|
/// If true, the connection has been shut down. We need to be careful not to accidentally
|
||||||
/// call `Sink::poll_complete` or `Sink::start_send` after `Sink::close`.
|
/// call `Sink::poll_complete` or `Sink::start_send` after `Sink::close`.
|
||||||
is_shutdown: bool,
|
is_shutdown: bool,
|
||||||
/// If true, the remote has sent data to us.
|
|
||||||
is_acknowledged: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Notifier {
|
struct Notifier {
|
||||||
@ -295,7 +292,6 @@ where C: AsyncRead + AsyncWrite + Unpin,
|
|||||||
};
|
};
|
||||||
|
|
||||||
trace!("Received message: {:?}", elem);
|
trace!("Received message: {:?}", elem);
|
||||||
inner.is_acknowledged = true;
|
|
||||||
|
|
||||||
// Handle substreams opening/closing.
|
// Handle substreams opening/closing.
|
||||||
match elem {
|
match elem {
|
||||||
@ -587,10 +583,6 @@ where C: AsyncRead + AsyncWrite + Unpin
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_remote_acknowledged(&self) -> bool {
|
|
||||||
self.inner.lock().is_acknowledged
|
|
||||||
}
|
|
||||||
|
|
||||||
fn close(&self, cx: &mut Context) -> Poll<Result<(), IoError>> {
|
fn close(&self, cx: &mut Context) -> Poll<Result<(), IoError>> {
|
||||||
let inner = &mut *self.inner.lock();
|
let inner = &mut *self.inner.lock();
|
||||||
if inner.is_shutdown {
|
if inner.is_shutdown {
|
||||||
|
@ -43,8 +43,6 @@ struct Inner<S> {
|
|||||||
incoming: S,
|
incoming: S,
|
||||||
/// Handle to control the connection.
|
/// Handle to control the connection.
|
||||||
control: yamux::Control,
|
control: yamux::Control,
|
||||||
/// True, once we have received an inbound substream.
|
|
||||||
acknowledged: bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A token to poll for an outbound substream.
|
/// A token to poll for an outbound substream.
|
||||||
@ -66,7 +64,6 @@ where
|
|||||||
_marker: std::marker::PhantomData
|
_marker: std::marker::PhantomData
|
||||||
},
|
},
|
||||||
control: ctrl,
|
control: ctrl,
|
||||||
acknowledged: false
|
|
||||||
};
|
};
|
||||||
Yamux(Mutex::new(inner))
|
Yamux(Mutex::new(inner))
|
||||||
}
|
}
|
||||||
@ -87,7 +84,6 @@ where
|
|||||||
_marker: std::marker::PhantomData
|
_marker: std::marker::PhantomData
|
||||||
},
|
},
|
||||||
control: ctrl,
|
control: ctrl,
|
||||||
acknowledged: false
|
|
||||||
};
|
};
|
||||||
Yamux(Mutex::new(inner))
|
Yamux(Mutex::new(inner))
|
||||||
}
|
}
|
||||||
@ -106,10 +102,7 @@ where
|
|||||||
fn poll_inbound(&self, c: &mut Context) -> Poll<Self::Substream> {
|
fn poll_inbound(&self, c: &mut Context) -> Poll<Self::Substream> {
|
||||||
let mut inner = self.0.lock();
|
let mut inner = self.0.lock();
|
||||||
match ready!(inner.incoming.poll_next_unpin(c)) {
|
match ready!(inner.incoming.poll_next_unpin(c)) {
|
||||||
Some(Ok(s)) => {
|
Some(Ok(s)) => Poll::Ready(Ok(s)),
|
||||||
inner.acknowledged = true;
|
|
||||||
Poll::Ready(Ok(s))
|
|
||||||
}
|
|
||||||
Some(Err(e)) => Poll::Ready(Err(e)),
|
Some(Err(e)) => Poll::Ready(Err(e)),
|
||||||
None => Poll::Ready(Err(yamux::ConnectionError::Closed.into()))
|
None => Poll::Ready(Err(yamux::ConnectionError::Closed.into()))
|
||||||
}
|
}
|
||||||
@ -146,10 +139,6 @@ where
|
|||||||
|
|
||||||
fn destroy_substream(&self, _: Self::Substream) { }
|
fn destroy_substream(&self, _: Self::Substream) { }
|
||||||
|
|
||||||
fn is_remote_acknowledged(&self) -> bool {
|
|
||||||
self.0.lock().acknowledged
|
|
||||||
}
|
|
||||||
|
|
||||||
fn close(&self, c: &mut Context) -> Poll<()> {
|
fn close(&self, c: &mut Context) -> Poll<()> {
|
||||||
let mut inner = self.0.lock();
|
let mut inner = self.0.lock();
|
||||||
if let std::task::Poll::Ready(x) = Pin::new(&mut inner.control).poll_close(c) {
|
if let std::task::Poll::Ready(x) = Pin::new(&mut inner.control).poll_close(c) {
|
||||||
|
Reference in New Issue
Block a user