Skip to content

Commit 2b79f11

Browse files
core/muxing: Remove the StreamMuxer::flush_all function (#2669)
`libp2p-core` provides the `StreamMuxer` abstraction so it can provide functionality that abstracts over this trait. We never use the `flush_all` function as part of our abstractions. No one else is going to use it so we can remove it from the abstraction.
1 parent 25c8bc2 commit 2b79f11

File tree

6 files changed

+5
-39
lines changed

6 files changed

+5
-39
lines changed

core/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# 0.33.0 [unreleased]
22

33
- Have methods on `Transport` take `&mut self` instead of `self`. See [PR 2529].
4+
- Remove `StreamMuxer::flush_all`. See [PR 2669].
45
- Rename `StreamMuxer::close` to `StreamMuxer::poll_close`. See [PR 2666].
56
- Remove deprecated function `StreamMuxer::is_remote_acknowledged`. See [PR 2665].
67

78
[PR 2529]: https://github.com/libp2p/rust-libp2p/pull/2529
89
[PR 2666]: https://github.com/libp2p/rust-libp2p/pull/2666
910
[PR 2665]: https://github.com/libp2p/rust-libp2p/pull/2665
11+
[PR 2669]: https://github.com/libp2p/rust-libp2p/pull/2669
12+
1013

1114
# 0.32.1
1215

core/src/either.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -352,13 +352,6 @@ where
352352
EitherOutput::Second(inner) => inner.poll_close(cx).map_err(|e| e.into()),
353353
}
354354
}
355-
356-
fn flush_all(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
357-
match self {
358-
EitherOutput::First(inner) => inner.flush_all(cx).map_err(|e| e.into()),
359-
EitherOutput::Second(inner) => inner.flush_all(cx).map_err(|e| e.into()),
360-
}
361-
}
362355
}
363356

364357
#[derive(Debug, Copy, Clone)]

core/src/muxing.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,6 @@ pub trait StreamMuxer {
216216
/// > properly informing the remote, there is no difference between this and
217217
/// > immediately dropping the muxer.
218218
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
219-
220-
/// Flush this `StreamMuxer`.
221-
///
222-
/// This drains any write buffers of substreams and delivers any pending shutdown notifications
223-
/// due to `shutdown_substream` or `close`. One may thus shutdown groups of substreams
224-
/// followed by a final `flush_all` instead of having to do `flush_substream` for each.
225-
fn flush_all(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
226219
}
227220

228221
/// Event about a connection, reported by an implementation of [`StreamMuxer`].
@@ -609,11 +602,6 @@ impl StreamMuxer for StreamMuxerBox {
609602
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
610603
self.inner.poll_close(cx)
611604
}
612-
613-
#[inline]
614-
fn flush_all(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
615-
self.inner.flush_all(cx)
616-
}
617605
}
618606

619607
struct Wrap<T>
@@ -750,9 +738,4 @@ where
750738
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
751739
self.inner.poll_close(cx).map_err(|e| e.into())
752740
}
753-
754-
#[inline]
755-
fn flush_all(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
756-
self.inner.flush_all(cx).map_err(|e| e.into())
757-
}
758741
}

core/src/muxing/singleton.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,7 @@ where
149149

150150
fn destroy_substream(&self, _: Self::Substream) {}
151151

152-
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
153-
// The `StreamMuxer` trait requires that `close()` implies `flush_all()`.
154-
self.flush_all(cx)
155-
}
156-
157-
fn flush_all(&self, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
158-
AsyncWrite::poll_flush(Pin::new(&mut *self.inner.lock()), cx)
152+
fn poll_close(&self, _cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
153+
Poll::Ready(Ok(()))
159154
}
160155
}

muxers/mplex/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,6 @@ where
172172
fn poll_close(&self, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
173173
self.io.lock().poll_close(cx)
174174
}
175-
176-
fn flush_all(&self, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
177-
self.io.lock().poll_flush(cx)
178-
}
179175
}
180176

181177
/// Active attempt to open an outbound substream.

muxers/yamux/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,6 @@ where
191191
}
192192
Poll::Pending
193193
}
194-
195-
fn flush_all(&self, _: &mut Context<'_>) -> Poll<YamuxResult<()>> {
196-
Poll::Ready(Ok(()))
197-
}
198194
}
199195

200196
/// The yamux configuration.

0 commit comments

Comments
 (0)