mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 23:57:56 +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
@@ -22,8 +22,7 @@ mod tests;
|
||||
use std::{sync::Arc, convert::TryInto};
|
||||
use log::warn;
|
||||
|
||||
use sc_client::Client;
|
||||
use sp_blockchain::Error as ClientError;
|
||||
use sp_blockchain::{Error as ClientError, HeaderBackend};
|
||||
|
||||
use rpc::futures::{
|
||||
Sink, Future,
|
||||
@@ -36,7 +35,7 @@ use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId};
|
||||
use codec::{Encode, Decode};
|
||||
use sp_core::{Bytes, traits::BareCryptoStorePtr};
|
||||
use sp_api::ProvideRuntimeApi;
|
||||
use sp_runtime::{generic, traits};
|
||||
use sp_runtime::generic;
|
||||
use sp_transaction_pool::{
|
||||
TransactionPool, InPoolTransaction, TransactionStatus,
|
||||
BlockHash, TxHash, TransactionFor, error::IntoPoolError,
|
||||
@@ -48,9 +47,9 @@ pub use sc_rpc_api::author::*;
|
||||
use self::error::{Error, FutureResult, Result};
|
||||
|
||||
/// Authoring API
|
||||
pub struct Author<B, E, P, Block: traits::Block, RA> {
|
||||
pub struct Author<P, Client> {
|
||||
/// Substrate client
|
||||
client: Arc<Client<B, E, Block, RA>>,
|
||||
client: Arc<Client>,
|
||||
/// Transactions pool
|
||||
pool: Arc<P>,
|
||||
/// Subscriptions manager
|
||||
@@ -59,10 +58,10 @@ pub struct Author<B, E, P, Block: traits::Block, RA> {
|
||||
keystore: BareCryptoStorePtr,
|
||||
}
|
||||
|
||||
impl<B, E, P, Block: traits::Block, RA> Author<B, E, P, Block, RA> {
|
||||
impl<P, Client> Author<P, Client> {
|
||||
/// Create new instance of Authoring API.
|
||||
pub fn new(
|
||||
client: Arc<Client<B, E, Block, RA>>,
|
||||
client: Arc<Client>,
|
||||
pool: Arc<P>,
|
||||
subscriptions: Subscriptions,
|
||||
keystore: BareCryptoStorePtr,
|
||||
@@ -76,18 +75,11 @@ impl<B, E, P, Block: traits::Block, RA> Author<B, E, P, Block, RA> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<B, E, P, RA> AuthorApi<TxHash<P>, BlockHash<P>>
|
||||
for Author<B, E, P, <P as TransactionPool>::Block, RA>
|
||||
where
|
||||
B: sc_client_api::backend::Backend<<P as TransactionPool>::Block> + Send + Sync + 'static,
|
||||
E: sc_client::CallExecutor<<P as TransactionPool>::Block> + Send + Sync + 'static,
|
||||
P: TransactionPool + Sync + Send + 'static,
|
||||
P::Block: traits::Block,
|
||||
P::Error: 'static,
|
||||
RA: Send + Sync + 'static,
|
||||
Client<B, E, P::Block, RA>: ProvideRuntimeApi<P::Block>,
|
||||
<Client<B, E, P::Block, RA> as ProvideRuntimeApi<P::Block>>::Api:
|
||||
SessionKeys<P::Block, Error = ClientError>,
|
||||
impl<P, Client> AuthorApi<TxHash<P>, BlockHash<P>> for Author<P, Client>
|
||||
where
|
||||
P: TransactionPool + Sync + Send + 'static,
|
||||
Client: HeaderBackend<P::Block> + ProvideRuntimeApi<P::Block> + Send + Sync + 'static,
|
||||
Client::Api: SessionKeys<P::Block, Error = ClientError>,
|
||||
{
|
||||
type Metadata = crate::metadata::Metadata;
|
||||
|
||||
@@ -105,7 +97,7 @@ where
|
||||
}
|
||||
|
||||
fn rotate_keys(&self) -> Result<Bytes> {
|
||||
let best_block_hash = self.client.chain_info().best_hash;
|
||||
let best_block_hash = self.client.info().best_hash;
|
||||
self.client.runtime_api().generate_session_keys(
|
||||
&generic::BlockId::Hash(best_block_hash),
|
||||
None,
|
||||
@@ -113,7 +105,7 @@ where
|
||||
}
|
||||
|
||||
fn has_session_keys(&self, session_keys: Bytes) -> Result<bool> {
|
||||
let best_block_hash = self.client.chain_info().best_hash;
|
||||
let best_block_hash = self.client.info().best_hash;
|
||||
let keys = self.client.runtime_api().decode_session_keys(
|
||||
&generic::BlockId::Hash(best_block_hash),
|
||||
session_keys.to_vec(),
|
||||
@@ -133,7 +125,7 @@ where
|
||||
Ok(xt) => xt,
|
||||
Err(err) => return Box::new(result(Err(err.into()))),
|
||||
};
|
||||
let best_block_hash = self.client.chain_info().best_hash;
|
||||
let best_block_hash = self.client.info().best_hash;
|
||||
Box::new(self.pool
|
||||
.submit_one(&generic::BlockId::hash(best_block_hash), xt)
|
||||
.compat()
|
||||
@@ -176,7 +168,7 @@ where
|
||||
xt: Bytes,
|
||||
) {
|
||||
let submit = || -> Result<_> {
|
||||
let best_block_hash = self.client.chain_info().best_hash;
|
||||
let best_block_hash = self.client.info().best_hash;
|
||||
let dxt = TransactionFor::<P>::decode(&mut &xt[..])
|
||||
.map_err(error::Error::from)?;
|
||||
Ok(
|
||||
|
||||
@@ -25,8 +25,8 @@ use sp_core::{
|
||||
};
|
||||
use rpc::futures::Stream as _;
|
||||
use substrate_test_runtime_client::{
|
||||
self, AccountKeyring, runtime::{Extrinsic, Transfer, SessionKeys, RuntimeApi, Block},
|
||||
DefaultTestClientBuilderExt, TestClientBuilderExt, Backend, Client, Executor,
|
||||
self, AccountKeyring, runtime::{Extrinsic, Transfer, SessionKeys, Block},
|
||||
DefaultTestClientBuilderExt, TestClientBuilderExt, Backend, Client,
|
||||
};
|
||||
use sc_transaction_pool::{BasicPool, FullChainApi};
|
||||
use tokio::runtime;
|
||||
@@ -75,7 +75,7 @@ impl Default for TestSetup {
|
||||
}
|
||||
|
||||
impl TestSetup {
|
||||
fn author(&self) -> Author<Backend, Executor, FullTransactionPool, Block, RuntimeApi> {
|
||||
fn author(&self) -> Author<FullTransactionPool, Client<Backend>> {
|
||||
Author {
|
||||
client: self.client.clone(),
|
||||
pool: self.pool.clone(),
|
||||
|
||||
Reference in New Issue
Block a user