mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 13:48:00 +00:00
Upgrade from futures-preview to futures 0.3.1, and remove futures 0.1 where currently possible (#4083)
* Migrate node and node-template * Migrate srml * Simple changes * Add async-std for interval * Fix test-runtime warning * Small changes * move futures01 in core/rpc to dev-deps * Change wasm CI builds * Switch to async-std 1.0.1 * Remove async-std dep of network * Add modified lockfile * Fix node cli browser build * Remove authority-discovery async-std dep * Add Send + Sync to interval dyn stream
This commit is contained in:
@@ -25,8 +25,8 @@ crate-type = ["cdylib", "rlib"]
|
||||
# third-party dependencies
|
||||
codec = { package = "parity-scale-codec", version = "1.0.6" }
|
||||
serde = { version = "1.0.102", features = [ "derive" ] }
|
||||
futures = "0.1.29"
|
||||
futures03 = { package = "futures-preview", version = "0.3.0-alpha.19", features = ["compat"] }
|
||||
futures01 = { package = "futures", version = "0.1.29" }
|
||||
futures = { version = "0.3.1", features = ["compat"] }
|
||||
hex-literal = "0.2.1"
|
||||
jsonrpc-core = "14.0.3"
|
||||
log = "0.4.8"
|
||||
@@ -80,7 +80,6 @@ node-executor = { path = "../executor" }
|
||||
|
||||
# CLI-specific dependencies
|
||||
tokio = { version = "0.1.22", optional = true }
|
||||
exit-future = { version = "0.1.4", optional = true }
|
||||
substrate-cli = { path = "../../../client/cli", optional = true }
|
||||
transaction-factory = { path = "../../../test/utils/transaction-factory", optional = true }
|
||||
ctrlc = { version = "3.1.3", features = ["termination"], optional = true }
|
||||
@@ -101,7 +100,7 @@ keystore = { package = "substrate-keystore", path = "../../../client/keystore" }
|
||||
babe = { package = "substrate-consensus-babe", path = "../../../client/consensus/babe", features = ["test-helpers"] }
|
||||
consensus-common = { package = "substrate-consensus-common", path = "../../../primitives/consensus/common" }
|
||||
service-test = { package = "substrate-service-test", path = "../../../client/service/test" }
|
||||
futures03 = { package = "futures-preview", version = "0.3.0-alpha.19" }
|
||||
futures = "0.3.1"
|
||||
tempfile = "3.1.0"
|
||||
|
||||
[build-dependencies]
|
||||
@@ -128,7 +127,6 @@ cli = [
|
||||
"substrate-cli",
|
||||
"transaction-factory",
|
||||
"tokio",
|
||||
"exit-future",
|
||||
"ctrlc",
|
||||
"substrate-service/rocksdb",
|
||||
"node-executor/wasmi-errno",
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
#![warn(missing_docs)]
|
||||
|
||||
use futures::sync::oneshot;
|
||||
use futures::{future, Future};
|
||||
use futures::channel::oneshot;
|
||||
use futures::{future, FutureExt};
|
||||
use substrate_cli::VersionInfo;
|
||||
|
||||
use std::cell::RefCell;
|
||||
@@ -27,7 +27,7 @@ use std::cell::RefCell;
|
||||
// handles ctrl-c
|
||||
struct Exit;
|
||||
impl substrate_cli::IntoExit for Exit {
|
||||
type Exit = future::MapErr<oneshot::Receiver<()>, fn(oneshot::Canceled) -> ()>;
|
||||
type Exit = future::Map<oneshot::Receiver<()>, fn(Result<(), oneshot::Canceled>) -> ()>;
|
||||
fn into_exit(self) -> Self::Exit {
|
||||
// can't use signal directly here because CtrlC takes only `Fn`.
|
||||
let (exit_send, exit) = oneshot::channel();
|
||||
@@ -39,7 +39,7 @@ impl substrate_cli::IntoExit for Exit {
|
||||
}
|
||||
}).expect("Error setting Ctrl-C handler");
|
||||
|
||||
exit.map_err(drop)
|
||||
exit.map(|_| ())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::ChainSpec;
|
||||
use futures::{prelude::*, sync::oneshot, sync::mpsc};
|
||||
use futures01::{prelude::*, sync::oneshot, sync::mpsc};
|
||||
use libp2p::wasm_ext;
|
||||
use log::{debug, info};
|
||||
use std::sync::Arc;
|
||||
@@ -71,7 +71,7 @@ fn start_inner(wasm_ext: wasm_ext::ffi::Transport) -> Result<Client, Box<dyn std
|
||||
// `service.poll()`.
|
||||
// The rest consists in handling RPC requests.
|
||||
let (rpc_send_tx, mut rpc_send_rx) = mpsc::unbounded::<RpcMessage>();
|
||||
wasm_bindgen_futures::spawn_local(futures::future::poll_fn(move || {
|
||||
wasm_bindgen_futures::spawn_local(futures01::future::poll_fn(move || {
|
||||
loop {
|
||||
match rpc_send_rx.poll() {
|
||||
Ok(Async::Ready(Some(message))) => {
|
||||
|
||||
@@ -185,23 +185,34 @@ where
|
||||
T: AbstractService,
|
||||
E: IntoExit,
|
||||
{
|
||||
let (exit_send, exit) = exit_future::signal();
|
||||
use futures::{FutureExt, TryFutureExt, channel::oneshot, future::select, compat::Future01CompatExt};
|
||||
|
||||
let (exit_send, exit) = oneshot::channel();
|
||||
|
||||
let informant = substrate_cli::informant::build(&service);
|
||||
runtime.executor().spawn(exit.until(informant).map(|_| ()));
|
||||
|
||||
let future = select(informant, exit)
|
||||
.map(|_| Ok(()))
|
||||
.compat();
|
||||
|
||||
runtime.executor().spawn(future);
|
||||
|
||||
// we eagerly drop the service so that the internal exit future is fired,
|
||||
// but we need to keep holding a reference to the global telemetry guard
|
||||
let _telemetry = service.telemetry();
|
||||
|
||||
let service_res = {
|
||||
let exit = e.into_exit().map_err(|_| error::Error::Other("Exit future failed.".into()));
|
||||
let service = service.map_err(|err| error::Error::Service(err));
|
||||
let select = service.select(exit).map(|_| ()).map_err(|(err, _)| err);
|
||||
let exit = e.into_exit();
|
||||
let service = service
|
||||
.map_err(|err| error::Error::Service(err))
|
||||
.compat();
|
||||
let select = select(service, exit)
|
||||
.map(|_| Ok(()))
|
||||
.compat();
|
||||
runtime.block_on(select)
|
||||
};
|
||||
|
||||
exit_send.fire();
|
||||
let _ = exit_send.send(());
|
||||
|
||||
// TODO [andre]: timeout this future #1318
|
||||
let _ = runtime.shutdown_on_idle().wait();
|
||||
|
||||
@@ -110,9 +110,9 @@ macro_rules! new_full_start {
|
||||
/// concrete types instead.
|
||||
macro_rules! new_full {
|
||||
($config:expr, $with_startup_data: expr) => {{
|
||||
use futures::sync::mpsc;
|
||||
use futures01::sync::mpsc;
|
||||
use network::DhtEvent;
|
||||
use futures03::{
|
||||
use futures::{
|
||||
compat::Stream01CompatExt,
|
||||
stream::StreamExt,
|
||||
future::{FutureExt, TryFutureExt},
|
||||
@@ -515,7 +515,7 @@ mod tests {
|
||||
digest.push(<DigestItem as CompatibleDigestItem>::babe_pre_digest(babe_pre_digest));
|
||||
|
||||
let mut proposer = proposer_factory.init(&parent_header).unwrap();
|
||||
let new_block = futures03::executor::block_on(proposer.propose(
|
||||
let new_block = futures::executor::block_on(proposer.propose(
|
||||
inherent_data,
|
||||
digest,
|
||||
std::time::Duration::from_secs(1),
|
||||
|
||||
Reference in New Issue
Block a user