mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 00:31:07 +00:00
Switch the client to new futures (#3103)
* Switch the client to new futures * No need for compat in the client * Fix client tests * Address review
This commit is contained in:
committed by
Bastian Köcher
parent
f5e921281e
commit
bf2551a854
@@ -19,7 +19,7 @@
|
||||
use std::sync::Arc;
|
||||
use std::collections::BTreeMap;
|
||||
use std::marker::PhantomData;
|
||||
use futures::IntoFuture;
|
||||
use std::future::Future;
|
||||
|
||||
use hash_db::{HashDB, Hasher};
|
||||
use parity_codec::{Decode, Encode};
|
||||
@@ -141,15 +141,15 @@ pub struct RemoteBodyRequest<Header: HeaderT> {
|
||||
/// is correct (see FetchedDataChecker) and return already checked data.
|
||||
pub trait Fetcher<Block: BlockT>: Send + Sync {
|
||||
/// Remote header future.
|
||||
type RemoteHeaderResult: IntoFuture<Item = Block::Header, Error = ClientError>;
|
||||
type RemoteHeaderResult: Future<Output = Result<Block::Header, ClientError>>;
|
||||
/// Remote storage read future.
|
||||
type RemoteReadResult: IntoFuture<Item = Option<Vec<u8>>, Error = ClientError>;
|
||||
type RemoteReadResult: Future<Output = Result<Option<Vec<u8>>, ClientError>>;
|
||||
/// Remote call result future.
|
||||
type RemoteCallResult: IntoFuture<Item = Vec<u8>, Error = ClientError>;
|
||||
type RemoteCallResult: Future<Output = Result<Vec<u8>, ClientError>>;
|
||||
/// Remote changes result future.
|
||||
type RemoteChangesResult: IntoFuture<Item = Vec<(NumberFor<Block>, u32)>, Error = ClientError>;
|
||||
type RemoteChangesResult: Future<Output = Result<Vec<(NumberFor<Block>, u32)>, ClientError>>;
|
||||
/// Remote block body result future.
|
||||
type RemoteBodyResult: IntoFuture<Item = Vec<Block::Extrinsic>, Error = ClientError>;
|
||||
type RemoteBodyResult: Future<Output = Result<Vec<Block::Extrinsic>, ClientError>>;
|
||||
|
||||
/// Fetch remote header.
|
||||
fn remote_header(&self, request: RemoteHeaderRequest<Block::Header>) -> Self::RemoteHeaderResult;
|
||||
@@ -484,7 +484,7 @@ impl<'a, H, Number, Hash> ChangesTrieRootsStorage<H, Number> for RootsStorage<'a
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use futures::future::{ok, err, FutureResult};
|
||||
use futures::future::Ready;
|
||||
use parking_lot::Mutex;
|
||||
use parity_codec::Decode;
|
||||
use crate::client::tests::prepare_client_with_key_changes;
|
||||
@@ -508,19 +508,19 @@ pub mod tests {
|
||||
|
||||
pub type OkCallFetcher = Mutex<Vec<u8>>;
|
||||
|
||||
fn not_implemented_in_tests<T, E>() -> FutureResult<T, E>
|
||||
fn not_implemented_in_tests<T, E>() -> Ready<Result<T, E>>
|
||||
where
|
||||
E: std::convert::From<&'static str>,
|
||||
{
|
||||
err("Not implemented on test node".into())
|
||||
futures::future::ready(Err("Not implemented on test node".into()))
|
||||
}
|
||||
|
||||
impl Fetcher<Block> for OkCallFetcher {
|
||||
type RemoteHeaderResult = FutureResult<Header, ClientError>;
|
||||
type RemoteReadResult = FutureResult<Option<Vec<u8>>, ClientError>;
|
||||
type RemoteCallResult = FutureResult<Vec<u8>, ClientError>;
|
||||
type RemoteChangesResult = FutureResult<Vec<(NumberFor<Block>, u32)>, ClientError>;
|
||||
type RemoteBodyResult = FutureResult<Vec<Extrinsic>, ClientError>;
|
||||
type RemoteHeaderResult = Ready<Result<Header, ClientError>>;
|
||||
type RemoteReadResult = Ready<Result<Option<Vec<u8>>, ClientError>>;
|
||||
type RemoteCallResult = Ready<Result<Vec<u8>, ClientError>>;
|
||||
type RemoteChangesResult = Ready<Result<Vec<(NumberFor<Block>, u32)>, ClientError>>;
|
||||
type RemoteBodyResult = Ready<Result<Vec<Extrinsic>, ClientError>>;
|
||||
|
||||
fn remote_header(&self, _request: RemoteHeaderRequest<Header>) -> Self::RemoteHeaderResult {
|
||||
not_implemented_in_tests()
|
||||
@@ -535,7 +535,7 @@ pub mod tests {
|
||||
}
|
||||
|
||||
fn remote_call(&self, _request: RemoteCallRequest<Header>) -> Self::RemoteCallResult {
|
||||
ok((*self.lock()).clone())
|
||||
futures::future::ready(Ok((*self.lock()).clone()))
|
||||
}
|
||||
|
||||
fn remote_changes(&self, _request: RemoteChangesRequest<Header>) -> Self::RemoteChangesResult {
|
||||
|
||||
Reference in New Issue
Block a user