From 500cea02f6a5f6170e172db09fee291985138338 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Wed, 8 Jul 2020 11:16:39 +0200 Subject: [PATCH] Remove AwaitCanceled --- network/Cargo.toml | 2 +- network/src/protocol/mod.rs | 26 ++------------------------ 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/network/Cargo.toml b/network/Cargo.toml index bfee6f34550b..a18115ac6dfc 100644 --- a/network/Cargo.toml +++ b/network/Cargo.toml @@ -19,7 +19,7 @@ sc-network = { git = "https://github.com/paritytech/substrate", branch = "master sc-network-gossip = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } -futures = "0.3.4" +futures = "0.3.5" log = "0.4.8" exit-future = "0.2.0" futures-timer = "2.0" diff --git a/network/src/protocol/mod.rs b/network/src/protocol/mod.rs index 0ed2d9ac4395..92eb6c5b004d 100644 --- a/network/src/protocol/mod.rs +++ b/network/src/protocol/mod.rs @@ -395,28 +395,6 @@ struct ConsensusNetworkingInstance { _drop_signal: exit_future::Signal, } -/// A utility future that resolves when the receiving end of a channel has hung up. -/// -/// This is an `.await`-friendly interface around `poll_canceled`. -// TODO: remove in favor of https://github.com/rust-lang/futures-rs/pull/2092/ -// once published. -#[must_use = "futures do nothing unless you `.await` or poll them"] -#[derive(Debug)] -pub struct AwaitCanceled<'a, T> { - inner: &'a mut oneshot::Sender, -} - -impl Future for AwaitCanceled<'_, T> { - type Output = (); - - fn poll( - mut self: Pin<&mut Self>, - cx: &mut futures::task::Context<'_>, - ) -> futures::task::Poll<()> { - self.inner.poll_canceled(cx) - } -} - /// Protocol configuration. #[derive(Default)] pub struct Config { @@ -933,7 +911,7 @@ impl Worker where let get_msg = fetch_pov_from_gossip(&candidate, &self.gossip_handle); let _ = self.executor.spawn(async move { - let res = future::select(get_msg, AwaitCanceled { inner: &mut sender }).await; + let res = future::select(get_msg, sender.cancellation()).await; if let Either::Left((pov_block, _)) = res { let _ = sender.send(pov_block); } @@ -964,7 +942,7 @@ impl Worker where )); let _ = self.executor.spawn(async move { - let res = future::select(get_msg, AwaitCanceled { inner: &mut sender }).await; + let res = future::select(get_msg, sender.cancellation()).await; if let Either::Left((chunk, _)) = res { let _ = sender.send(chunk); }