mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 13:21:10 +00:00
Update the service to std futures (#4447)
* Switch service to futures03 * Fix tests * Fix service test and cli * Re-add Executor trait to SpawnTaskHandle * Fix node-service * Update babe * Fix browser node * Update aura * Revert back to tokio-executor to fix runtime panic * Add todo item * Fix service tests again * Timeout test futures * Fix tests * nits * Fix service test * Remove zstd patch * Re-add futures01 to aura and babe tests as a dev-dep * Change failing test to tee * Fix node * Upgrade tokio * fix society * Start switching grandpa to stable futures * Revert "Start switching grandpa to stable futures" This reverts commit 9c1976346237637effc07c13f7d0403daf5e71cf. * Fix utils * Revert substrate service test * Revert gitlab Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
@@ -22,9 +22,6 @@ use crate::error::Error;
|
||||
use sc_chain_spec::{ChainSpec, RuntimeGenesis, Extension};
|
||||
use log::{warn, info};
|
||||
use futures::{future, prelude::*};
|
||||
use futures03::{
|
||||
TryFutureExt as _,
|
||||
};
|
||||
use sp_runtime::traits::{
|
||||
Block as BlockT, NumberFor, One, Zero, Header, SaturatedConversion
|
||||
};
|
||||
@@ -34,9 +31,7 @@ use sc_client::Client;
|
||||
use sp_consensus::import_queue::{IncomingBlock, Link, BlockImportError, BlockImportResult, ImportQueue};
|
||||
use sp_consensus::BlockOrigin;
|
||||
|
||||
use std::{
|
||||
io::{Read, Write, Seek},
|
||||
};
|
||||
use std::{io::{Read, Write, Seek}, pin::Pin};
|
||||
|
||||
use sc_network::message;
|
||||
|
||||
@@ -68,7 +63,7 @@ impl<
|
||||
self,
|
||||
input: impl Read + Seek + Send + 'static,
|
||||
force: bool,
|
||||
) -> Box<dyn Future<Item = (), Error = Error> + Send> {
|
||||
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
|
||||
struct WaitLink {
|
||||
imported_blocks: u64,
|
||||
has_error: bool,
|
||||
@@ -117,7 +112,7 @@ impl<
|
||||
// queue, the `Future` re-schedules itself and returns `Poll::Pending`.
|
||||
// This makes it possible either to interleave other operations in-between the block imports,
|
||||
// or to stop the operation completely.
|
||||
let import = futures03::future::poll_fn(move |cx| {
|
||||
let import = future::poll_fn(move |cx| {
|
||||
// Start by reading the number of blocks if not done so already.
|
||||
let count = match count {
|
||||
Some(c) => c,
|
||||
@@ -205,7 +200,7 @@ impl<
|
||||
return std::task::Poll::Pending;
|
||||
}
|
||||
});
|
||||
Box::new(import.compat())
|
||||
Box::pin(import)
|
||||
}
|
||||
|
||||
fn export_blocks(
|
||||
@@ -214,7 +209,7 @@ impl<
|
||||
from: NumberFor<TBl>,
|
||||
to: Option<NumberFor<TBl>>,
|
||||
json: bool
|
||||
) -> Box<dyn Future<Item = (), Error = Error>> {
|
||||
) -> Pin<Box<dyn Future<Output = Result<(), Error>>>> {
|
||||
let client = self.client;
|
||||
let mut block = from;
|
||||
|
||||
@@ -233,7 +228,7 @@ impl<
|
||||
// `Poll::Pending`.
|
||||
// This makes it possible either to interleave other operations in-between the block exports,
|
||||
// or to stop the operation completely.
|
||||
let export = futures03::future::poll_fn(move |cx| {
|
||||
let export = future::poll_fn(move |cx| {
|
||||
if last < block {
|
||||
return std::task::Poll::Ready(Err("Invalid block range specified".into()));
|
||||
}
|
||||
@@ -274,7 +269,7 @@ impl<
|
||||
std::task::Poll::Pending
|
||||
});
|
||||
|
||||
Box::new(export.compat())
|
||||
Box::pin(export)
|
||||
}
|
||||
|
||||
fn revert_chain(
|
||||
@@ -295,7 +290,7 @@ impl<
|
||||
fn check_block(
|
||||
self,
|
||||
block_id: BlockId<TBl>
|
||||
) -> Box<dyn Future<Item = (), Error = Error> + Send> {
|
||||
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
|
||||
match self.client.block(&block_id) {
|
||||
Ok(Some(block)) => {
|
||||
let mut buf = Vec::new();
|
||||
@@ -304,8 +299,8 @@ impl<
|
||||
let reader = std::io::Cursor::new(buf);
|
||||
self.import_blocks(reader, true)
|
||||
}
|
||||
Ok(None) => Box::new(future::err("Unknown block".into())),
|
||||
Err(e) => Box::new(future::err(format!("Error reading block: {:?}", e).into())),
|
||||
Ok(None) => Box::pin(future::err("Unknown block".into())),
|
||||
Err(e) => Box::pin(future::err(format!("Error reading block: {:?}", e).into())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user