Deprecate StreamMuxer::is_remote_acknowledged (#1616)

This commit is contained in:
Pierre Krieger
2020-06-19 11:59:24 +02:00
committed by GitHub
parent 563d3374ed
commit 00fc223487
7 changed files with 7 additions and 67 deletions

View File

@ -230,14 +230,6 @@ where
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
/// `Future` that resolves when connection shutdown is complete.
pub fn close(self) -> Close<TMuxer> {

View File

@ -123,13 +123,6 @@ where
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
/// that signals the remote that we shut down the connection.
#[must_use]

View File

@ -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>> {
match self {
EitherOutput::First(inner) => inner.close(cx).map_err(|e| e.into()),

View File

@ -64,8 +64,7 @@ mod singleton;
///
/// 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
/// operate on this.
/// - A connection to the remote. The `flush_all` and `close` methods operate on this.
/// - A list of substreams that are open. The `poll_inbound`, `poll_outbound`, `read_substream`,
/// `write_substream`, `flush_substream`, `shutdown_substream` and `destroy_substream` methods
/// 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
/// method can be called in order to determine whether the remote has accepted our handshake or
/// 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`.
///
@ -525,11 +527,6 @@ impl StreamMuxer for StreamMuxerBox {
self.inner.close(cx)
}
#[inline]
fn is_remote_acknowledged(&self) -> bool {
self.inner.is_remote_acknowledged()
}
#[inline]
fn flush_all(&self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
self.inner.flush_all(cx)
@ -631,11 +628,6 @@ where
self.inner.close(cx).map_err(|e| e.into())
}
#[inline]
fn is_remote_acknowledged(&self) -> bool {
self.inner.is_remote_acknowledged()
}
#[inline]
fn flush_all(&self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
self.inner.flush_all(cx).map_err(|e| e.into())

View File

@ -35,8 +35,6 @@ pub struct SingletonMuxer<TSocket> {
substream_extracted: AtomicBool,
/// Our local endpoint. Always the same value as was passed to `new`.
endpoint: Endpoint,
/// If true, we have received data from the remote.
remote_acknowledged: AtomicBool,
}
impl<TSocket> SingletonMuxer<TSocket> {
@ -49,7 +47,6 @@ impl<TSocket> SingletonMuxer<TSocket> {
inner: Mutex::new(inner),
substream_extracted: AtomicBool::new(false),
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>> {
let res = 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
AsyncRead::poll_read(Pin::new(&mut *self.inner.lock()), cx, buf)
}
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 is_remote_acknowledged(&self) -> bool {
self.remote_acknowledged.load(Ordering::Acquire)
}
fn close(&self, cx: &mut Context) -> Poll<Result<(), io::Error>> {
// The `StreamMuxer` trait requires that `close()` implies `flush_all()`.
self.flush_all(cx)