Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 308e8b4

Browse files
authored
Remove AwaitCanceled (#1375)
1 parent b651e4a commit 308e8b4

File tree

2 files changed

+3
-25
lines changed

2 files changed

+3
-25
lines changed

network/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ sc-network = { git = "https://github.com/paritytech/substrate", branch = "master
1919
sc-network-gossip = { git = "https://github.com/paritytech/substrate", branch = "master" }
2020
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
2121
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
22-
futures = "0.3.4"
22+
futures = "0.3.5"
2323
log = "0.4.8"
2424
exit-future = "0.2.0"
2525
futures-timer = "2.0"

network/src/protocol/mod.rs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -404,28 +404,6 @@ struct ConsensusNetworkingInstance {
404404
_drop_signal: exit_future::Signal,
405405
}
406406

407-
/// A utility future that resolves when the receiving end of a channel has hung up.
408-
///
409-
/// This is an `.await`-friendly interface around `poll_canceled`.
410-
// TODO: remove in favor of https://github.com/rust-lang/futures-rs/pull/2092/
411-
// once published.
412-
#[must_use = "futures do nothing unless you `.await` or poll them"]
413-
#[derive(Debug)]
414-
pub struct AwaitCanceled<'a, T> {
415-
inner: &'a mut oneshot::Sender<T>,
416-
}
417-
418-
impl<T> Future for AwaitCanceled<'_, T> {
419-
type Output = ();
420-
421-
fn poll(
422-
mut self: Pin<&mut Self>,
423-
cx: &mut futures::task::Context<'_>,
424-
) -> futures::task::Poll<()> {
425-
self.inner.poll_canceled(cx)
426-
}
427-
}
428-
429407
/// Protocol configuration.
430408
#[derive(Default)]
431409
pub struct Config {
@@ -947,7 +925,7 @@ impl<Api, Sp, Gossip> Worker<Api, Sp, Gossip> where
947925
self.executor.spawn(
948926
"polkadot-fetch-pov-block",
949927
async move {
950-
let res = future::select(get_msg, AwaitCanceled { inner: &mut sender }).await;
928+
let res = future::select(get_msg, sender.cancellation()).await;
951929
if let Either::Left((pov_block, _)) = res {
952930
let _ = sender.send(pov_block);
953931
}
@@ -981,7 +959,7 @@ impl<Api, Sp, Gossip> Worker<Api, Sp, Gossip> where
981959
self.executor.spawn(
982960
"polkadot-fetch-erasure-chunk",
983961
async move {
984-
let res = future::select(get_msg, AwaitCanceled { inner: &mut sender }).await;
962+
let res = future::select(get_msg, sender.cancellation()).await;
985963
if let Either::Left((chunk, _)) = res {
986964
let _ = sender.send(chunk);
987965
}

0 commit comments

Comments
 (0)