Refactor sr-api to not depend on client anymore (#4086)

* Refactor sr-api to not depend on client anymore

* Fix benches

* Apply suggestions from code review

Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* Apply suggestions from code review
This commit is contained in:
Bastian Köcher
2019-11-11 16:26:49 +01:00
committed by Benjamin Kampmann
parent e26d1a0b3e
commit 2ecffa1cd0
140 changed files with 1514 additions and 984 deletions
+3 -1
View File
@@ -10,7 +10,7 @@ default = ["rocksdb"]
# a path to a database, an error will be produced at runtime.
rocksdb = ["client_db/kvdb-rocksdb"]
wasmtime = [
"substrate-executor/wasmtime",
"substrate-executor/wasmtime",
]
[dependencies]
@@ -38,6 +38,8 @@ consensus_common = { package = "substrate-consensus-common", path = "../../core/
network = { package = "substrate-network", path = "../../core/network" }
chain-spec = { package = "substrate-chain-spec", path = "../chain-spec" }
client = { package = "substrate-client", path = "../../core/client" }
sr-api = { path = "../sr-api" }
tx-pool-api = { package = "substrate-transaction-pool-runtime-api", path = "../transaction-pool/runtime-api" }
client_db = { package = "substrate-client-db", path = "../../core/client/db" }
codec = { package = "parity-scale-codec", version = "1.0.0" }
substrate-executor = { path = "../../core/executor" }
+9 -7
View File
@@ -19,8 +19,7 @@ use crate::{SpawnTaskHandle, start_rpc_servers, build_network_future, Transactio
use crate::status_sinks;
use crate::config::{Configuration, DatabaseConfig};
use client::{
BlockchainEvents, Client, runtime_api,
backend::RemoteBackend, light::blockchain::RemoteBlockchain,
BlockchainEvents, Client, backend::RemoteBackend, light::blockchain::RemoteBlockchain,
};
use chain_spec::{RuntimeGenesis, Extension};
use codec::{Decode, Encode, IoReader};
@@ -757,10 +756,11 @@ ServiceBuilder<
> where
Client<TBackend, TExec, TBl, TRtApi>: ProvideRuntimeApi,
<Client<TBackend, TExec, TBl, TRtApi> as ProvideRuntimeApi>::Api:
runtime_api::Metadata<TBl> +
sr_api::Metadata<TBl> +
offchain::OffchainWorkerApi<TBl> +
runtime_api::TaggedTransactionQueue<TBl> +
session::SessionKeys<TBl>,
tx_pool_api::TaggedTransactionQueue<TBl> +
session::SessionKeys<TBl> +
sr_api::ApiExt<TBl, Error = client::error::Error>,
TBl: BlockT<Hash = <Blake2Hasher as Hasher>::Out>,
TRtApi: 'static + Send + Sync,
TCfg: Default,
@@ -808,7 +808,8 @@ ServiceBuilder<
session::generate_initial_session_keys(
client.clone(),
config.dev_key_seed.clone().map(|s| vec![s]).unwrap_or_default()
&BlockId::Hash(client.info().chain.best_hash),
config.dev_key_seed.clone().map(|s| vec![s]).unwrap_or_default(),
)?;
let (signal, exit) = exit_future::signal();
@@ -1162,7 +1163,8 @@ pub(crate) fn maintain_transaction_pool<Api, Backend, Block, Executor, PoolApi>(
Block: BlockT<Hash = <Blake2Hasher as primitives::Hasher>::Out>,
Backend: 'static + client::backend::Backend<Block, Blake2Hasher>,
Client<Backend, Executor, Block, Api>: ProvideRuntimeApi,
<Client<Backend, Executor, Block, Api> as ProvideRuntimeApi>::Api: runtime_api::TaggedTransactionQueue<Block>,
<Client<Backend, Executor, Block, Api> as ProvideRuntimeApi>::Api:
tx_pool_api::TaggedTransactionQueue<Block>,
Executor: 'static + client::CallExecutor<Block, Blake2Hasher>,
PoolApi: 'static + txpool::ChainApi<Hash = Block::Hash, Block = Block>,
Api: 'static,
+2 -2
View File
@@ -36,7 +36,7 @@ use std::time::{Duration, Instant};
use futures::sync::mpsc;
use parking_lot::Mutex;
use client::{runtime_api::BlockT, Client};
use client::Client;
use exit_future::Signal;
use futures::prelude::*;
use futures03::{
@@ -51,7 +51,7 @@ use log::{log, warn, debug, error, Level};
use codec::{Encode, Decode};
use primitives::{Blake2Hasher, H256};
use sr_primitives::generic::BlockId;
use sr_primitives::traits::NumberFor;
use sr_primitives::traits::{NumberFor, Block as BlockT};
pub use self::error::Error;
pub use self::builder::{ServiceBuilder, ServiceBuilderExport, ServiceBuilderImport, ServiceBuilderRevert};