mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 13:01:07 +00:00
Update exit-future and make sc-cli compile on wasm (#4289)
* updated exit-future (github repo) * Switch to broadcast crate * Migrate client/cli * Switch exit-future to modernize branch * Small changes * Switch to cargo version and fix fg tests * Revert "Small changes" This reverts commit a488106805d220cb4aee9e46a71481424c6d87d5.
This commit is contained in:
Generated
+21
-17
@@ -418,6 +418,11 @@ dependencies = [
|
||||
"iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "c2-chacha"
|
||||
version = "0.2.3"
|
||||
@@ -1097,11 +1102,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "exit-future"
|
||||
version = "0.1.4"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1556,14 +1560,6 @@ dependencies = [
|
||||
"slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures01"
|
||||
version = "0.1.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fxhash"
|
||||
version = "0.2.1"
|
||||
@@ -2709,7 +2705,6 @@ name = "lock_api"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@@ -4912,7 +4907,6 @@ dependencies = [
|
||||
"env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures01 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -4933,7 +4927,7 @@ dependencies = [
|
||||
"structopt 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tokio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5452,7 +5446,7 @@ name = "sc-service"
|
||||
version = "2.0.0"
|
||||
dependencies = [
|
||||
"derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"exit-future 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"grafana-data-source 2.0.0",
|
||||
@@ -6910,6 +6904,15 @@ dependencies = [
|
||||
"tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pin-project-lite 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-buf"
|
||||
version = "0.1.1"
|
||||
@@ -7977,6 +7980,7 @@ dependencies = [
|
||||
"checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855"
|
||||
"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
|
||||
"checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c"
|
||||
"checksum bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c85319f157e4e26c703678e68e26ab71a46c0199286fa670b21cc9fec13d895"
|
||||
"checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb"
|
||||
"checksum c_linked_list 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4964518bd3b4a8190e832886cdc0da9794f12e8e6c1613a9e90ff331c4c8724b"
|
||||
"checksum cargo_metadata 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8d2d1617e838936c0d2323a65cc151e03ae19a7678dd24f72bccf27119b90a5d"
|
||||
@@ -8048,7 +8052,7 @@ dependencies = [
|
||||
"checksum evm-core 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bcde5af3d542874ddeb53de0919302d57586ea04b3f76f54d865f8a6cdc70ae"
|
||||
"checksum evm-gasometer 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b82bc9f275cb59d2bcc05d85c98736ddfaba003a7ef7b73893fa7c1c1fab29dc"
|
||||
"checksum evm-runtime 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0dbbc89d29618c3722c17ba78ddf432d40ace8ee27e3f8b28b52a85921112e4b"
|
||||
"checksum exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d8013f441e38e31c670e7f34ec8f1d5d3a2bd9d303c1ff83976ca886005e8f48"
|
||||
"checksum exit-future 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e43f2f1833d64e33f15592464d6fdd70f349dda7b1a53088eb83cd94014008c5"
|
||||
"checksum faerie 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f902f2af041f6c7177a2a04f805687cdc71e69c7cbef059a2755d8923f4cd7a8"
|
||||
"checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9"
|
||||
"checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08"
|
||||
@@ -8085,7 +8089,6 @@ dependencies = [
|
||||
"checksum futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a1de7508b218029b0f01662ed8f61b1c964b3ae99d6f25462d0f55a595109df6"
|
||||
"checksum futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76"
|
||||
"checksum futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "5ce968633c17e5f97936bd2797b6e38fb56cf16a7422319f7ec2e30d3c470e8d"
|
||||
"checksum futures01 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "7ef8cbbf52909170053540c6c05a62433ddb60662dabee714e2a882caa864f22"
|
||||
"checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
|
||||
"checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2"
|
||||
"checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"
|
||||
@@ -8389,6 +8392,7 @@ dependencies = [
|
||||
"checksum tiny-keccak 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2953ca5148619bc99695c1274cb54c5275bbb913c6adad87e72eaf8db9787f69"
|
||||
"checksum tinytemplate 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4574b75faccaacddb9b284faecdf0b544b80b6b294f3d062d325c5726a209c20"
|
||||
"checksum tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6"
|
||||
"checksum tokio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2e765bf9f550bd9b8a970633ca3b56b8120c4b6c5dcbe26a93744cb02fee4b17"
|
||||
"checksum tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46"
|
||||
"checksum tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c501eceaf96f0e1793cf26beb63da3d11c738c4a943fdf3746d81d64684c39f"
|
||||
"checksum tokio-codec 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9f5d22fd1e84bd4045d28813491cb7d7caae34d45c80517c2213f09a85e8787a"
|
||||
|
||||
@@ -16,9 +16,8 @@ time = "0.1.42"
|
||||
ansi_term = "0.12.1"
|
||||
lazy_static = "1.4.0"
|
||||
app_dirs = "1.2.1"
|
||||
tokio = "0.1.22"
|
||||
tokio = "0.2.1"
|
||||
futures = { version = "0.3.1", features = ["compat"] }
|
||||
futures01 = "0.1.29"
|
||||
fdlimit = "0.1.1"
|
||||
serde_json = "1.0.41"
|
||||
panic-handler = { package = "sp-panic-handler", path = "../../primitives/panic-handler" }
|
||||
@@ -33,9 +32,11 @@ sc-telemetry = { path = "../telemetry" }
|
||||
keyring = { package = "sp-keyring", path = "../../primitives/keyring" }
|
||||
names = "0.11.0"
|
||||
structopt = "0.3.3"
|
||||
rpassword = "4.0.1"
|
||||
sc-tracing = { package = "sc-tracing", path = "../tracing" }
|
||||
|
||||
[target.'cfg(not(target_os = "unknown"))'.dependencies]
|
||||
rpassword = "4.0.1"
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3.1.0"
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ use primitives::H256;
|
||||
|
||||
use std::{
|
||||
io::{Write, Read, Seek, Cursor, stdin, stdout, ErrorKind}, iter, fs::{self, File},
|
||||
net::{Ipv4Addr, SocketAddr}, path::{Path, PathBuf}, str::FromStr,
|
||||
net::{Ipv4Addr, SocketAddr}, path::{Path, PathBuf}, str::FromStr, pin::Pin, task::Poll
|
||||
};
|
||||
|
||||
use names::{Generator, Name};
|
||||
@@ -61,8 +61,7 @@ pub use traits::{GetLogFilter, AugmentClap};
|
||||
use app_dirs::{AppInfo, AppDataType};
|
||||
use log::info;
|
||||
use lazy_static::lazy_static;
|
||||
use futures::{Future, FutureExt, TryFutureExt};
|
||||
use futures01::{Async, Future as _};
|
||||
use futures::{Future, compat::Future01CompatExt, executor::block_on};
|
||||
use sc_telemetry::TelemetryEndpoints;
|
||||
use sp_runtime::generic::BlockId;
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
@@ -396,23 +395,23 @@ impl<'a> ParseAndPrepareExport<'a> {
|
||||
// Note: while we would like the user to handle the exit themselves, we handle it here
|
||||
// for backwards compatibility reasons.
|
||||
let (exit_send, exit_recv) = std::sync::mpsc::channel();
|
||||
let exit = exit.into_exit()
|
||||
.map(|_| Ok::<_, ()>(()))
|
||||
.compat();
|
||||
let exit = exit.into_exit();
|
||||
std::thread::spawn(move || {
|
||||
let _ = exit.wait();
|
||||
block_on(exit);
|
||||
let _ = exit_send.send(());
|
||||
});
|
||||
|
||||
let mut export_fut = builder(config)?.export_blocks(file, from.into(), to.map(Into::into), json);
|
||||
let fut = futures01::future::poll_fn(|| {
|
||||
let mut export_fut = builder(config)?
|
||||
.export_blocks(file, from.into(), to.map(Into::into), json)
|
||||
.compat();
|
||||
let fut = futures::future::poll_fn(|cx| {
|
||||
if exit_recv.try_recv().is_ok() {
|
||||
return Ok(Async::Ready(()));
|
||||
return Poll::Ready(Ok(()));
|
||||
}
|
||||
export_fut.poll()
|
||||
Pin::new(&mut export_fut).poll(cx)
|
||||
});
|
||||
|
||||
let mut runtime = tokio::runtime::current_thread::Runtime::new().unwrap();
|
||||
let mut runtime = tokio::runtime::Runtime::new().unwrap();
|
||||
runtime.block_on(fut)?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -455,23 +454,23 @@ impl<'a> ParseAndPrepareImport<'a> {
|
||||
// Note: while we would like the user to handle the exit themselves, we handle it here
|
||||
// for backwards compatibility reasons.
|
||||
let (exit_send, exit_recv) = std::sync::mpsc::channel();
|
||||
let exit = exit.into_exit()
|
||||
.map(|_| Ok::<_, ()>(()))
|
||||
.compat();
|
||||
let exit = exit.into_exit();
|
||||
std::thread::spawn(move || {
|
||||
let _ = exit.wait();
|
||||
block_on(exit);
|
||||
let _ = exit_send.send(());
|
||||
});
|
||||
|
||||
let mut import_fut = builder(config)?.import_blocks(file, false);
|
||||
let fut = futures01::future::poll_fn(|| {
|
||||
let mut import_fut = builder(config)?
|
||||
.import_blocks(file, false)
|
||||
.compat();
|
||||
let fut = futures::future::poll_fn(|cx| {
|
||||
if exit_recv.try_recv().is_ok() {
|
||||
return Ok(Async::Ready(()));
|
||||
return Poll::Ready(Ok(()));
|
||||
}
|
||||
import_fut.poll()
|
||||
Pin::new(&mut import_fut).poll(cx)
|
||||
});
|
||||
|
||||
let mut runtime = tokio::runtime::current_thread::Runtime::new().unwrap();
|
||||
let mut runtime = tokio::runtime::Runtime::new().unwrap();
|
||||
runtime.block_on(fut)?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -513,8 +512,10 @@ impl<'a> CheckBlock<'a> {
|
||||
};
|
||||
|
||||
let start = std::time::Instant::now();
|
||||
let check = builder(config)?.check_block(block_id);
|
||||
let mut runtime = tokio::runtime::current_thread::Runtime::new().unwrap();
|
||||
let check = builder(config)?
|
||||
.check_block(block_id)
|
||||
.compat();
|
||||
let mut runtime = tokio::runtime::Runtime::new().unwrap();
|
||||
runtime.block_on(check)?;
|
||||
println!("Completed in {} ms.", start.elapsed().as_millis());
|
||||
Ok(())
|
||||
@@ -719,6 +720,7 @@ fn fill_network_configuration(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
fn input_keystore_password() -> Result<String, String> {
|
||||
rpassword::read_password_from_tty(Some("Keystore password: "))
|
||||
.map_err(|e| format!("{:?}", e))
|
||||
@@ -730,7 +732,12 @@ fn fill_config_keystore_password<C, G, E>(
|
||||
cli: &RunCmd,
|
||||
) -> Result<(), String> {
|
||||
config.keystore_password = if cli.password_interactive {
|
||||
Some(input_keystore_password()?.into())
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
{
|
||||
Some(input_keystore_password()?.into())
|
||||
}
|
||||
#[cfg(target_os = "unknown")]
|
||||
None
|
||||
} else if let Some(ref file) = cli.password_filename {
|
||||
Some(fs::read_to_string(file).map_err(|e| format!("{}", e))?.into())
|
||||
} else if let Some(ref password) = cli.password {
|
||||
|
||||
@@ -289,7 +289,7 @@ impl<B: BlockT, N: Network<B>> NetworkBridge<B, N> {
|
||||
service: N,
|
||||
config: crate::Config,
|
||||
set_state: crate::environment::SharedVoterSetState<B>,
|
||||
on_exit: impl Future<Item = (), Error = ()> + Clone + Send + 'static,
|
||||
on_exit: impl futures03::Future<Output = ()> + Clone + Send + Unpin + 'static,
|
||||
) -> (
|
||||
Self,
|
||||
impl Future<Item = (), Error = ()> + Send + 'static,
|
||||
@@ -350,9 +350,20 @@ impl<B: BlockT, N: Network<B>> NetworkBridge<B, N> {
|
||||
// lazily spawn these jobs onto their own tasks. the lazy future has access
|
||||
// to tokio globals, which aren't available outside.
|
||||
let mut executor = tokio_executor::DefaultExecutor::current();
|
||||
executor.spawn(Box::new(rebroadcast_job.select(on_exit.clone()).then(|_| Ok(()))))
|
||||
|
||||
use futures03::{FutureExt, TryFutureExt};
|
||||
|
||||
let rebroadcast_job = rebroadcast_job
|
||||
.select(on_exit.clone().map(Ok).compat())
|
||||
.then(|_| Ok(()));
|
||||
|
||||
let reporting_job = reporting_job
|
||||
.select(on_exit.clone().map(Ok).compat())
|
||||
.then(|_| Ok(()));
|
||||
|
||||
executor.spawn(Box::new(rebroadcast_job))
|
||||
.expect("failed to spawn grandpa rebroadcast job task");
|
||||
executor.spawn(Box::new(reporting_job.select(on_exit.clone()).then(|_| Ok(()))))
|
||||
executor.spawn(Box::new(reporting_job))
|
||||
.expect("failed to spawn grandpa reporting job task");
|
||||
Ok(())
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@ use std::sync::Arc;
|
||||
use keyring::Ed25519Keyring;
|
||||
use codec::Encode;
|
||||
use sp_runtime::traits::NumberFor;
|
||||
|
||||
use std::{pin::Pin, task::{Context, Poll}};
|
||||
use crate::environment::SharedVoterSetState;
|
||||
use fg_primitives::AuthorityList;
|
||||
use super::gossip::{self, GossipValidator};
|
||||
@@ -175,12 +175,11 @@ fn make_test_network() -> (
|
||||
#[derive(Clone)]
|
||||
struct Exit;
|
||||
|
||||
impl Future for Exit {
|
||||
type Item = ();
|
||||
type Error = ();
|
||||
impl futures03::Future for Exit {
|
||||
type Output = ();
|
||||
|
||||
fn poll(&mut self) -> Poll<(), ()> {
|
||||
Ok(Async::NotReady)
|
||||
fn poll(self: Pin<&mut Self>, _: &mut Context) -> Poll<()> {
|
||||
Poll::Pending
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -555,7 +555,7 @@ pub fn run_grandpa_voter<B, E, Block: BlockT<Hash=H256>, N, RA, SC, VR, X>(
|
||||
NumberFor<Block>: BlockNumberOps,
|
||||
DigestFor<Block>: Encode,
|
||||
RA: Send + Sync + 'static,
|
||||
X: Future<Item=(),Error=()> + Clone + Send + 'static,
|
||||
X: futures03::Future<Output=()> + Clone + Send + Unpin + 'static,
|
||||
{
|
||||
let GrandpaParams {
|
||||
config,
|
||||
@@ -634,7 +634,9 @@ pub fn run_grandpa_voter<B, E, Block: BlockT<Hash=H256>, N, RA, SC, VR, X>(
|
||||
let telemetry_task = telemetry_task
|
||||
.then(|_| futures::future::empty::<(), ()>());
|
||||
|
||||
Ok(voter_work.select(on_exit).select2(telemetry_task).then(|_| Ok(())))
|
||||
use futures03::{FutureExt, TryFutureExt};
|
||||
|
||||
Ok(voter_work.select(on_exit.map(Ok).compat()).select2(telemetry_task).then(|_| Ok(())))
|
||||
}
|
||||
|
||||
/// Future that powers the voter.
|
||||
@@ -889,7 +891,7 @@ pub fn run_grandpa<B, E, Block: BlockT<Hash=H256>, N, RA, SC, VR, X>(
|
||||
DigestFor<Block>: Encode,
|
||||
RA: Send + Sync + 'static,
|
||||
VR: VotingRule<Block, Client<B, E, Block, RA>> + Clone + 'static,
|
||||
X: Future<Item=(),Error=()> + Clone + Send + 'static,
|
||||
X: futures03::Future<Output=()> + Clone + Send + Unpin + 'static,
|
||||
{
|
||||
run_grandpa_voter(grandpa_params)
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ pub fn run_grandpa_observer<B, E, Block: BlockT<Hash=H256>, N, RA, SC>(
|
||||
config: Config,
|
||||
link: LinkHalf<B, E, Block, RA, SC>,
|
||||
network: N,
|
||||
on_exit: impl Future<Item=(),Error=()> + Clone + Send + 'static,
|
||||
on_exit: impl futures03::Future<Output=()> + Clone + Send + Unpin + 'static,
|
||||
) -> ::sp_blockchain::Result<impl Future<Item=(),Error=()> + Send + 'static> where
|
||||
B: Backend<Block, Blake2Hasher> + 'static,
|
||||
E: CallExecutor<Block, Blake2Hasher> + Send + Sync + 'static,
|
||||
@@ -195,7 +195,9 @@ pub fn run_grandpa_observer<B, E, Block: BlockT<Hash=H256>, N, RA, SC>(
|
||||
|
||||
let observer_work = network_startup.and_then(move |()| observer_work);
|
||||
|
||||
Ok(observer_work.select(on_exit).map(|_| ()).map_err(|_| ()))
|
||||
use futures03::{FutureExt, TryFutureExt};
|
||||
|
||||
Ok(observer_work.select(on_exit.map(Ok).compat()).map(|_| ()).map_err(|_| ()))
|
||||
}
|
||||
|
||||
/// Future that powers the observer.
|
||||
|
||||
@@ -39,6 +39,7 @@ use sp_runtime::generic::{BlockId, DigestItem};
|
||||
use primitives::{NativeOrEncoded, ExecutionContext, crypto::Public};
|
||||
use fg_primitives::{GRANDPA_ENGINE_ID, AuthorityList, GrandpaApi};
|
||||
use state_machine::{backend::InMemory, prove_read, read_proof_check};
|
||||
use std::{pin::Pin, task};
|
||||
|
||||
use authorities::AuthoritySet;
|
||||
use finality_proof::{FinalityProofProvider, AuthoritySetForFinalityProver, AuthoritySetForFinalityChecker};
|
||||
@@ -175,12 +176,11 @@ impl TestNetFactory for GrandpaTestNet {
|
||||
#[derive(Clone)]
|
||||
struct Exit;
|
||||
|
||||
impl Future for Exit {
|
||||
type Item = ();
|
||||
type Error = ();
|
||||
impl futures03::Future for Exit {
|
||||
type Output = ();
|
||||
|
||||
fn poll(&mut self) -> Poll<(), ()> {
|
||||
Ok(Async::NotReady)
|
||||
fn poll(self: Pin<&mut Self>, _: &mut task::Context) -> task::Poll<()> {
|
||||
task::Poll::Pending
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ log = "0.4.8"
|
||||
slog = { version = "2.5.2", features = ["nested-values"] }
|
||||
tokio-executor = "0.1.8"
|
||||
tokio-timer = "0.2.11"
|
||||
exit-future = "0.1.4"
|
||||
exit-future = "0.2.0"
|
||||
serde = "1.0.101"
|
||||
serde_json = "1.0.41"
|
||||
sysinfo = "0.9.5"
|
||||
|
||||
@@ -28,7 +28,7 @@ use chain_spec::{RuntimeGenesis, Extension};
|
||||
use consensus_common::import_queue::ImportQueue;
|
||||
use futures::{prelude::*, sync::mpsc};
|
||||
use futures03::{
|
||||
compat::{Compat, Future01CompatExt},
|
||||
compat::Compat,
|
||||
FutureExt as _, TryFutureExt as _,
|
||||
StreamExt as _, TryStreamExt as _,
|
||||
future::{select, Either}
|
||||
@@ -880,7 +880,7 @@ ServiceBuilder<
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.select(exit.clone())
|
||||
.select(exit.clone().map(Ok).compat())
|
||||
.then(|_| Ok(()));
|
||||
let _ = to_spawn_tx.unbounded_send(Box::new(events));
|
||||
}
|
||||
@@ -902,7 +902,7 @@ ServiceBuilder<
|
||||
);
|
||||
Ok(())
|
||||
})
|
||||
.select(exit.clone())
|
||||
.select(exit.clone().map(Ok).compat())
|
||||
.then(|_| Ok(()));
|
||||
|
||||
let _ = to_spawn_tx.unbounded_send(Box::new(events));
|
||||
@@ -967,7 +967,7 @@ ServiceBuilder<
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}).select(exit.clone()).then(|_| Ok(()));
|
||||
}).select(exit.clone().map(Ok).compat()).then(|_| Ok(()));
|
||||
let _ = to_spawn_tx.unbounded_send(Box::new(tel_task));
|
||||
|
||||
// Periodically send the network state to the telemetry.
|
||||
@@ -980,7 +980,7 @@ ServiceBuilder<
|
||||
"state" => network_state,
|
||||
);
|
||||
Ok(())
|
||||
}).select(exit.clone()).then(|_| Ok(()));
|
||||
}).select(exit.clone().map(Ok).compat()).then(|_| Ok(()));
|
||||
let _ = to_spawn_tx.unbounded_send(Box::new(tel_task_2));
|
||||
|
||||
// RPC
|
||||
@@ -1054,7 +1054,7 @@ ServiceBuilder<
|
||||
dht_event_tx,
|
||||
)
|
||||
.map_err(|_| ())
|
||||
.select(exit.clone())
|
||||
.select(exit.clone().map(Ok).compat())
|
||||
.then(|_| Ok(()))));
|
||||
|
||||
let telemetry_connection_sinks: Arc<Mutex<Vec<mpsc::UnboundedSender<()>>>> = Default::default();
|
||||
@@ -1099,7 +1099,7 @@ ServiceBuilder<
|
||||
Ok(())
|
||||
});
|
||||
let _ = to_spawn_tx.unbounded_send(Box::new(future
|
||||
.select(exit.clone())
|
||||
.select(exit.clone().map(Ok).compat())
|
||||
.then(|_| Ok(()))));
|
||||
telemetry
|
||||
});
|
||||
@@ -1108,7 +1108,7 @@ ServiceBuilder<
|
||||
if let Some(port) = config.grafana_port {
|
||||
let future = select(
|
||||
grafana_data_source::run_server(port).boxed(),
|
||||
exit.clone().compat()
|
||||
exit.clone()
|
||||
).map(|either| match either {
|
||||
Either::Left((result, _)) => result.map_err(|_| ()),
|
||||
Either::Right(_) => Ok(())
|
||||
|
||||
@@ -120,7 +120,8 @@ impl Executor<Box<dyn Future<Item = (), Error = ()> + Send>> for SpawnTaskHandle
|
||||
&self,
|
||||
future: Box<dyn Future<Item = (), Error = ()> + Send>,
|
||||
) -> Result<(), futures::future::ExecuteError<Box<dyn Future<Item = (), Error = ()> + Send>>> {
|
||||
let future = Box::new(future.select(self.on_exit.clone()).then(|_| Ok(())));
|
||||
let exit = self.on_exit.clone().map(Ok).compat();
|
||||
let future = Box::new(future.select(exit).then(|_| Ok(())));
|
||||
if let Err(err) = self.sender.unbounded_send(future) {
|
||||
let kind = futures::future::ExecuteErrorKind::Shutdown;
|
||||
Err(futures::future::ExecuteError::new(kind, err.into_inner()))
|
||||
@@ -236,7 +237,8 @@ where
|
||||
}
|
||||
|
||||
fn spawn_task(&self, task: impl Future<Item = (), Error = ()> + Send + 'static) {
|
||||
let task = task.select(self.on_exit()).then(|_| Ok(()));
|
||||
let exit = self.on_exit().map(Ok).compat();
|
||||
let task = task.select(exit).then(|_| Ok(()));
|
||||
let _ = self.to_spawn_tx.unbounded_send(Box::new(task));
|
||||
}
|
||||
|
||||
@@ -249,7 +251,8 @@ where
|
||||
let _ = essential_failed.send(());
|
||||
Ok(())
|
||||
});
|
||||
let task = essential_task.select(self.on_exit()).then(|_| Ok(()));
|
||||
let exit = self.on_exit().map(Ok::<_, ()>).compat();
|
||||
let task = essential_task.select(exit).then(|_| Ok(()));
|
||||
|
||||
let _ = self.to_spawn_tx.unbounded_send(Box::new(task));
|
||||
}
|
||||
@@ -503,7 +506,7 @@ impl<TBl, TCl, TSc, TNetStatus, TNet, TTxPool, TOc> Drop for
|
||||
fn drop(&mut self) {
|
||||
debug!(target: "service", "Substrate service shutdown");
|
||||
if let Some(signal) = self.signal.take() {
|
||||
signal.fire();
|
||||
let _ = signal.fire();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user