Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/muxer: Deprecate StreamMuxerExt::next_{inbound,outbound} #3002

Merged
merged 5 commits into from Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/CHANGELOG.md
Expand Up @@ -5,8 +5,11 @@
- Remove default features. If you previously depended on `secp256k1` or `ecdsa` you need to enable these explicitly
now. See [PR 2918].

- Deprecate `StreamMuxerExt::next_{inbound,outbound}`. See [PR XXXX].

[PR 2915]: https://github.com/libp2p/rust-libp2p/pull/2915
[PR 2918]: https://github.com/libp2p/rust-libp2p/pull/2918
[PR XXXX]: https://github.com/libp2p/rust-libp2p/pull/XXXX
thomaseizinger marked this conversation as resolved.
Show resolved Hide resolved

# 0.36.0

Expand Down
8 changes: 8 additions & 0 deletions core/src/muxing.rs
Expand Up @@ -160,11 +160,19 @@ pub trait StreamMuxerExt: StreamMuxer + Sized {
}

/// Returns a future that resolves to the next inbound `Substream` opened by the remote.
#[deprecated(
since = "0.36.1",
note = "This future violates the `StreamMuxer` contract because it doesn't call `StreamMuxer::poll`."
)]
fn next_inbound(&mut self) -> NextInbound<'_, Self> {
NextInbound(self)
}

/// Returns a future that opens a new outbound `Substream` with the remote.
#[deprecated(
since = "0.36.1",
note = "This future violates the `StreamMuxer` contract because it doesn't call `StreamMuxer::poll`."
)]
fn next_outbound(&mut self) -> NextOutbound<'_, Self> {
NextOutbound(self)
}
Expand Down
8 changes: 6 additions & 2 deletions muxers/mplex/benches/split_send_size.rs
Expand Up @@ -114,7 +114,10 @@ fn run(
}
transport::TransportEvent::Incoming { upgrade, .. } => {
let (_peer, mut conn) = upgrade.await.unwrap();
let mut s = conn.next_inbound().await.expect("unexpected error");
// Just calling `poll_inbound` without `poll` is fine here because mplex makes progress through all `poll_` functions. It is hacky though.
let mut s = poll_fn(|cx| conn.poll_inbound_unpin(cx))
.await
.expect("unexpected error");

let mut buf = vec![0u8; payload_len];
let mut off = 0;
Expand All @@ -139,7 +142,8 @@ fn run(
let sender = async move {
let addr = addr_receiver.await.unwrap();
let (_peer, mut conn) = sender_trans.dial(addr).unwrap().await.unwrap();
let mut stream = conn.next_outbound().await.unwrap();
// Just calling `poll_outbound` without `poll` is fine here because mplex makes progress through all `poll_` functions. It is hacky though.
let mut stream = poll_fn(|cx| conn.poll_outbound_unpin(cx)).await.unwrap();
let mut off = 0;
loop {
let n = poll_fn(|cx| Pin::new(&mut stream).poll_write(cx, &payload[off..]))
Expand Down