mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-16 22:25:43 +00:00
removes use of sc_client::Client from sc-rpc (#5063)
* removes use of sc_client::Client from sc-rpc * remove Client impl from sc-finality-benches * remove client impl from sc-finality-grandpa * read_proof accepts iterator * remove generic Executor param from ExecutorProvider * fix long ass line * code style changes * merge with master Co-authored-by: Arkadiy Paronyan <arkady.paronyan@gmail.com>
This commit is contained in:
committed by
GitHub
parent
dc85ccb7df
commit
99ae5342eb
@@ -20,37 +20,39 @@ use std::sync::Arc;
|
||||
use rpc::futures::future::result;
|
||||
|
||||
use sc_rpc_api::Subscriptions;
|
||||
use sc_client_api::{CallExecutor, backend::Backend};
|
||||
use sc_client::Client;
|
||||
use sc_client_api::{BlockchainEvents, BlockBody};
|
||||
use sp_runtime::{generic::{BlockId, SignedBlock}, traits::{Block as BlockT}};
|
||||
|
||||
use super::{ChainBackend, client_err, error::FutureResult};
|
||||
use std::marker::PhantomData;
|
||||
use sp_blockchain::HeaderBackend;
|
||||
|
||||
/// Blockchain API backend for full nodes. Reads all the data from local database.
|
||||
pub struct FullChain<B, E, Block: BlockT, RA> {
|
||||
pub struct FullChain<Block: BlockT, Client> {
|
||||
/// Substrate client.
|
||||
client: Arc<Client<B, E, Block, RA>>,
|
||||
client: Arc<Client>,
|
||||
/// Current subscriptions.
|
||||
subscriptions: Subscriptions,
|
||||
/// phantom member to pin the block type
|
||||
_phantom: PhantomData<Block>,
|
||||
}
|
||||
|
||||
impl<B, E, Block: BlockT, RA> FullChain<B, E, Block, RA> {
|
||||
impl<Block: BlockT, Client> FullChain<Block, Client> {
|
||||
/// Create new Chain API RPC handler.
|
||||
pub fn new(client: Arc<Client<B, E, Block, RA>>, subscriptions: Subscriptions) -> Self {
|
||||
pub fn new(client: Arc<Client>, subscriptions: Subscriptions) -> Self {
|
||||
Self {
|
||||
client,
|
||||
subscriptions,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<B, E, Block, RA> ChainBackend<B, E, Block, RA> for FullChain<B, E, Block, RA> where
|
||||
impl<Block, Client> ChainBackend<Client, Block> for FullChain<Block, Client> where
|
||||
Block: BlockT + 'static,
|
||||
B: Backend<Block> + Send + Sync + 'static,
|
||||
E: CallExecutor<Block> + Send + Sync + 'static,
|
||||
RA: Send + Sync + 'static,
|
||||
Client: BlockBody<Block> + HeaderBackend<Block> + BlockchainEvents<Block> + 'static,
|
||||
{
|
||||
fn client(&self) -> &Arc<Client<B, E, Block, RA>> {
|
||||
fn client(&self) -> &Arc<Client> {
|
||||
&self.client
|
||||
}
|
||||
|
||||
@@ -60,7 +62,7 @@ impl<B, E, Block, RA> ChainBackend<B, E, Block, RA> for FullChain<B, E, Block, R
|
||||
|
||||
fn header(&self, hash: Option<Block::Hash>) -> FutureResult<Option<Block::Header>> {
|
||||
Box::new(result(self.client
|
||||
.header(&BlockId::Hash(self.unwrap_or_best(hash)))
|
||||
.header(BlockId::Hash(self.unwrap_or_best(hash)))
|
||||
.map_err(client_err)
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user