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:
Pierre Krieger
2019-07-11 16:58:30 +02:00
committed by Bastian Köcher
parent f5e921281e
commit bf2551a854
28 changed files with 249 additions and 112 deletions
+6 -3
View File
@@ -23,6 +23,7 @@ pub mod number;
mod tests;
use std::sync::Arc;
use futures03::{future, StreamExt as _, TryStreamExt as _};
use client::{self, Client, BlockchainEvents};
use crate::rpc::Result as RpcResult;
@@ -203,8 +204,9 @@ impl<B, E, Block, RA> ChainApi<NumberFor<Block>, Block::Hash, Block::Header, Sig
subscriber,
|| self.block_hash(None.into()),
|| self.client.import_notification_stream()
.filter(|notification| notification.is_new_best)
.map(|notification| notification.header),
.filter(|notification| future::ready(notification.is_new_best))
.map(|notification| Ok::<_, ()>(notification.header))
.compat(),
)
}
@@ -217,7 +219,8 @@ impl<B, E, Block, RA> ChainApi<NumberFor<Block>, Block::Hash, Block::Header, Sig
subscriber,
|| Ok(Some(self.client.info().chain.finalized_hash)),
|| self.client.finality_notification_stream()
.map(|notification| notification.header),
.map(|notification| Ok::<_, ()>(notification.header))
.compat(),
)
}