[big refactor] Remove crate aliasing. (#4395)

* Rename: Phase 1.

* Unify codec.

* Fixing: Phase 2

* Fixing: Phase 3.

* Fixing: Phase 4.

* Fixing: Phase 5.

* Fixing: Phase 6.

* Fixing: Phase 7.

* Fixing: Phase 8. Tests

* Fixing: Phase 9. Tests!!!

* Fixing: Phase 10. Moar tests!

* Finally done!

* More fixes.

* Rename primitives:: to sp_core::

* Apply renames in finality-grandpa.

* Fix benches.

* Fix benches 2.

* Revert node-template.

* Fix frame-system in our modules.
This commit is contained in:
Tomasz Drwięga
2019-12-16 13:36:49 +01:00
committed by Gavin Wood
parent f14d98a439
commit 8778ca7dc8
485 changed files with 4023 additions and 4005 deletions
+60 -60
View File
@@ -18,14 +18,14 @@ use crate::{Service, NetworkStatus, NetworkState, error::Error, DEFAULT_PROTOCOL
use crate::{SpawnTaskHandle, start_rpc_servers, build_network_future, TransactionPoolAdapter};
use crate::status_sinks;
use crate::config::{Configuration, DatabaseConfig};
use client_api::{
use sc_client_api::{
self,
BlockchainEvents,
backend::RemoteBackend, light::RemoteBlockchain,
};
use client::Client;
use chain_spec::{RuntimeGenesis, Extension};
use consensus_common::import_queue::ImportQueue;
use sc_client::Client;
use sc_chain_spec::{RuntimeGenesis, Extension};
use sp_consensus::import_queue::ImportQueue;
use futures::{prelude::*, sync::mpsc};
use futures03::{
compat::Compat,
@@ -33,13 +33,13 @@ use futures03::{
StreamExt as _, TryStreamExt as _,
future::{select, Either}
};
use keystore::{Store as Keystore};
use sc_keystore::{Store as Keystore};
use log::{info, warn, error};
use network::{FinalityProofProvider, OnDemand, NetworkService, NetworkStateInfo, DhtEvent};
use network::{config::BoxFinalityProofRequestBuilder, specialization::NetworkSpecialization};
use sc_network::{FinalityProofProvider, OnDemand, NetworkService, NetworkStateInfo, DhtEvent};
use sc_network::{config::BoxFinalityProofRequestBuilder, specialization::NetworkSpecialization};
use parking_lot::{Mutex, RwLock};
use primitives::{Blake2Hasher, H256, Hasher};
use rpc;
use sp_core::{Blake2Hasher, H256, Hasher};
use sc_rpc;
use sp_api::ConstructRuntimeApi;
use sp_runtime::generic::BlockId;
use sp_runtime::traits::{
@@ -51,7 +51,7 @@ use std::{
marker::PhantomData, sync::Arc, time::SystemTime
};
use sysinfo::{get_current_pid, ProcessExt, System, SystemExt};
use tel::{telemetry, SUBSTRATE_INFO};
use sc_telemetry::{telemetry, SUBSTRATE_INFO};
use sp_transaction_pool::{TransactionPool, TransactionPoolMaintainer};
use sp_blockchain;
use grafana_data_source::{self, record_metrics};
@@ -103,11 +103,11 @@ type TFullClient<TBl, TRtApi, TExecDisp> = Client<
>;
/// Full client backend type.
type TFullBackend<TBl> = client_db::Backend<TBl>;
type TFullBackend<TBl> = sc_client_db::Backend<TBl>;
/// Full client call executor type.
type TFullCallExecutor<TBl, TExecDisp> = client::LocalCallExecutor<
client_db::Backend<TBl>,
type TFullCallExecutor<TBl, TExecDisp> = sc_client::LocalCallExecutor<
sc_client_db::Backend<TBl>,
NativeExecutor<TExecDisp>,
>;
@@ -120,20 +120,20 @@ type TLightClient<TBl, TRtApi, TExecDisp> = Client<
>;
/// Light client backend type.
type TLightBackend<TBl> = client::light::backend::Backend<
client_db::light::LightStorage<TBl>,
type TLightBackend<TBl> = sc_client::light::backend::Backend<
sc_client_db::light::LightStorage<TBl>,
Blake2Hasher,
>;
/// Light call executor type.
type TLightCallExecutor<TBl, TExecDisp> = client::light::call_executor::GenesisCallExecutor<
client::light::backend::Backend<
client_db::light::LightStorage<TBl>,
type TLightCallExecutor<TBl, TExecDisp> = sc_client::light::call_executor::GenesisCallExecutor<
sc_client::light::backend::Backend<
sc_client_db::light::LightStorage<TBl>,
Blake2Hasher
>,
client::LocalCallExecutor<
client::light::backend::Backend<
client_db::light::LightStorage<TBl>,
sc_client::LocalCallExecutor<
sc_client::light::backend::Backend<
sc_client_db::light::LightStorage<TBl>,
Blake2Hasher
>,
NativeExecutor<TExecDisp>
@@ -174,33 +174,33 @@ where TGen: RuntimeGenesis, TCSExt: Extension {
let fork_blocks = config.chain_spec
.extensions()
.get::<client::ForkBlocks<TBl>>()
.get::<sc_client::ForkBlocks<TBl>>()
.cloned()
.unwrap_or_default();
let (client, backend) = {
let db_config = client_db::DatabaseSettings {
let db_config = sc_client_db::DatabaseSettings {
state_cache_size: config.state_cache_size,
state_cache_child_ratio:
config.state_cache_child_ratio.map(|v| (v, 100)),
pruning: config.pruning.clone(),
source: match &config.database {
DatabaseConfig::Path { path, cache_size } =>
client_db::DatabaseSettingsSrc::Path {
sc_client_db::DatabaseSettingsSrc::Path {
path: path.clone(),
cache_size: cache_size.clone().map(|u| u as usize),
},
DatabaseConfig::Custom(db) =>
client_db::DatabaseSettingsSrc::Custom(db.clone()),
sc_client_db::DatabaseSettingsSrc::Custom(db.clone()),
},
};
let extensions = client_api::execution_extensions::ExecutionExtensions::new(
let extensions = sc_client_api::execution_extensions::ExecutionExtensions::new(
config.execution_strategies.clone(),
Some(keystore.clone()),
);
client_db::new_client(
sc_client_db::new_client(
db_config,
executor,
&config.chain_spec,
@@ -261,29 +261,29 @@ where TGen: RuntimeGenesis, TCSExt: Extension {
);
let db_storage = {
let db_settings = client_db::DatabaseSettings {
let db_settings = sc_client_db::DatabaseSettings {
state_cache_size: config.state_cache_size,
state_cache_child_ratio:
config.state_cache_child_ratio.map(|v| (v, 100)),
pruning: config.pruning.clone(),
source: match &config.database {
DatabaseConfig::Path { path, cache_size } =>
client_db::DatabaseSettingsSrc::Path {
sc_client_db::DatabaseSettingsSrc::Path {
path: path.clone(),
cache_size: cache_size.clone().map(|u| u as usize),
},
DatabaseConfig::Custom(db) =>
client_db::DatabaseSettingsSrc::Custom(db.clone()),
sc_client_db::DatabaseSettingsSrc::Custom(db.clone()),
},
};
client_db::light::LightStorage::new(db_settings)?
sc_client_db::light::LightStorage::new(db_settings)?
};
let light_blockchain = client::light::new_light_blockchain(db_storage);
let fetch_checker = Arc::new(client::light::new_fetch_checker(light_blockchain.clone(), executor.clone()));
let fetcher = Arc::new(network::OnDemand::new(fetch_checker));
let backend = client::light::new_light_backend(light_blockchain);
let light_blockchain = sc_client::light::new_light_blockchain(db_storage);
let fetch_checker = Arc::new(sc_client::light::new_fetch_checker(light_blockchain.clone(), executor.clone()));
let fetcher = Arc::new(sc_network::OnDemand::new(fetch_checker));
let backend = sc_client::light::new_light_backend(light_blockchain);
let remote_blockchain = backend.remote_blockchain();
let client = Arc::new(client::light::new_light(
let client = Arc::new(sc_client::light::new_light(
backend.clone(),
&config.chain_spec,
executor,
@@ -559,7 +559,7 @@ impl<TBl, TRtApi, TCfg, TGen, TCSExt, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TNet
pub fn with_transaction_pool<UExPool>(
self,
transaction_pool_builder: impl FnOnce(
txpool::txpool::Options,
sc_transaction_pool::txpool::Options,
Arc<TCl>,
Option<TFchr>,
) -> Result<UExPool, Error>
@@ -713,24 +713,24 @@ ServiceBuilder<
Client<TBackend, TExec, TBl, TRtApi>: ProvideRuntimeApi,
<Client<TBackend, TExec, TBl, TRtApi> as ProvideRuntimeApi>::Api:
sp_api::Metadata<TBl> +
offchain::OffchainWorkerApi<TBl> +
sc_offchain::OffchainWorkerApi<TBl> +
sp_transaction_pool::runtime_api::TaggedTransactionQueue<TBl> +
session::SessionKeys<TBl> +
sp_session::SessionKeys<TBl> +
sp_api::ApiExt<TBl, Error = sp_blockchain::Error>,
TBl: BlockT<Hash = <Blake2Hasher as Hasher>::Out>,
TRtApi: ConstructRuntimeApi<TBl, Client<TBackend, TExec, TBl, TRtApi>> + 'static + Send + Sync,
TCfg: Default,
TGen: RuntimeGenesis,
TCSExt: Extension,
TBackend: 'static + client_api::backend::Backend<TBl, Blake2Hasher> + Send,
TExec: 'static + client::CallExecutor<TBl, Blake2Hasher> + Send + Sync + Clone,
TBackend: 'static + sc_client_api::backend::Backend<TBl, Blake2Hasher> + Send,
TExec: 'static + sc_client::CallExecutor<TBl, Blake2Hasher> + Send + Sync + Clone,
TSc: Clone,
TImpQu: 'static + ImportQueue<TBl>,
TNetP: NetworkSpecialization<TBl>,
TExPool: 'static
+ TransactionPool<Block=TBl, Hash = <TBl as BlockT>::Hash>
+ TransactionPoolMaintainer<Block=TBl, Hash = <TBl as BlockT>::Hash>,
TRpc: rpc::RpcExtension<rpc::Metadata> + Clone,
TRpc: sc_rpc::RpcExtension<sc_rpc::Metadata> + Clone,
{
/// Builds the service.
pub fn build(self) -> Result<Service<
@@ -740,7 +740,7 @@ ServiceBuilder<
NetworkStatus<TBl>,
NetworkService<TBl, TNetP, <TBl as BlockT>::Hash>,
TExPool,
offchain::OffchainWorkers<
sc_offchain::OffchainWorkers<
Client<TBackend, TExec, TBl, TRtApi>,
TBackend::OffchainStorage,
TBl
@@ -764,7 +764,7 @@ ServiceBuilder<
dht_event_tx,
} = self;
session::generate_initial_session_keys(
sp_session::generate_initial_session_keys(
client.clone(),
&BlockId::Hash(client.info().chain.best_hash),
config.dev_key_seed.clone().map(|s| vec![s]).unwrap_or_default(),
@@ -812,13 +812,13 @@ ServiceBuilder<
DEFAULT_PROTOCOL_ID
}
}.as_bytes();
network::config::ProtocolId::from(protocol_id_full)
sc_network::config::ProtocolId::from(protocol_id_full)
};
let block_announce_validator =
Box::new(consensus_common::block_validation::DefaultBlockAnnounceValidator::new(client.clone()));
Box::new(sp_consensus::block_validation::DefaultBlockAnnounceValidator::new(client.clone()));
let network_params = network::config::Params {
let network_params = sc_network::config::Params {
roles: config.roles,
network_config: config.network.clone(),
chain: client.clone(),
@@ -833,14 +833,14 @@ ServiceBuilder<
};
let has_bootnodes = !network_params.network_config.boot_nodes.is_empty();
let network_mut = network::NetworkWorker::new(network_params)?;
let network_mut = sc_network::NetworkWorker::new(network_params)?;
let network = network_mut.service().clone();
let network_status_sinks = Arc::new(Mutex::new(status_sinks::StatusSinks::new()));
let offchain_storage = backend.offchain_storage();
let offchain_workers = match (config.offchain_worker, offchain_storage) {
(true, Some(db)) => {
Some(Arc::new(offchain::OffchainWorkers::new(client.clone(), db)))
Some(Arc::new(sc_offchain::OffchainWorkers::new(client.clone(), db)))
},
(true, None) => {
log::warn!("Offchain workers disabled, due to lack of offchain storage support in backend.");
@@ -986,16 +986,16 @@ ServiceBuilder<
// RPC
let (system_rpc_tx, system_rpc_rx) = futures03::channel::mpsc::unbounded();
let gen_handler = || {
use rpc::{chain, state, author, system};
use sc_rpc::{chain, state, author, system};
let system_info = rpc::system::SystemInfo {
let system_info = sc_rpc::system::SystemInfo {
chain_name: config.chain_spec.name().into(),
impl_name: config.impl_name.into(),
impl_version: config.impl_version.into(),
properties: config.chain_spec.properties().clone(),
};
let subscriptions = rpc::Subscriptions::new(Arc::new(SpawnTaskHandle {
let subscriptions = sc_rpc::Subscriptions::new(Arc::new(SpawnTaskHandle {
sender: to_spawn_tx.clone(),
on_exit: exit.clone()
}));
@@ -1003,13 +1003,13 @@ ServiceBuilder<
let (chain, state) = if let (Some(remote_backend), Some(on_demand)) =
(remote_backend.as_ref(), on_demand.as_ref()) {
// Light clients
let chain = rpc::chain::new_light(
let chain = sc_rpc::chain::new_light(
client.clone(),
subscriptions.clone(),
remote_backend.clone(),
on_demand.clone()
);
let state = rpc::state::new_light(
let state = sc_rpc::state::new_light(
client.clone(),
subscriptions.clone(),
remote_backend.clone(),
@@ -1019,12 +1019,12 @@ ServiceBuilder<
} else {
// Full nodes
let chain = rpc::chain::new_full(client.clone(), subscriptions.clone());
let state = rpc::state::new_full(client.clone(), subscriptions.clone());
let chain = sc_rpc::chain::new_full(client.clone(), subscriptions.clone());
let state = sc_rpc::state::new_full(client.clone(), subscriptions.clone());
(chain, state)
};
let author = rpc::author::Author::new(
let author = sc_rpc::author::Author::new(
client.clone(),
transaction_pool.clone(),
subscriptions,
@@ -1032,7 +1032,7 @@ ServiceBuilder<
);
let system = system::System::new(system_info, system_rpc_tx.clone());
rpc_servers::rpc_handler((
sc_rpc_server::rpc_handler((
state::StateApi::to_delegate(state),
chain::ChainApi::to_delegate(chain),
author::AuthorApi::to_delegate(author),
@@ -1068,7 +1068,7 @@ ServiceBuilder<
let version = version.clone();
let chain_name = config.chain_spec.name().to_owned();
let telemetry_connection_sinks_ = telemetry_connection_sinks.clone();
let telemetry = tel::init_telemetry(tel::TelemetryConfig {
let telemetry = sc_telemetry::init_telemetry(sc_telemetry::TelemetryConfig {
endpoints,
wasm_external_transport: config.telemetry_external_transport.take(),
});
@@ -1080,7 +1080,7 @@ ServiceBuilder<
.compat()
.for_each(move |event| {
// Safe-guard in case we add more events in the future.
let tel::TelemetryEvent::Connected = event;
let sc_telemetry::TelemetryEvent::Connected = event;
telemetry!(SUBSTRATE_INFO; "system.connected";
"name" => name.clone(),
+8 -8
View File
@@ -19,27 +19,27 @@
use crate::error;
use crate::builder::{ServiceBuilderCommand, ServiceBuilder};
use crate::error::Error;
use chain_spec::{ChainSpec, RuntimeGenesis, Extension};
use sc_chain_spec::{ChainSpec, RuntimeGenesis, Extension};
use log::{warn, info};
use futures::{future, prelude::*};
use futures03::{
TryFutureExt as _,
};
use primitives::{Blake2Hasher, Hasher};
use sp_core::{Blake2Hasher, Hasher};
use sp_runtime::traits::{
Block as BlockT, NumberFor, One, Zero, Header, SaturatedConversion
};
use sp_runtime::generic::{BlockId, SignedBlock};
use codec::{Decode, Encode, IoReader};
use client::Client;
use consensus_common::import_queue::{IncomingBlock, Link, BlockImportError, BlockImportResult, ImportQueue};
use consensus_common::BlockOrigin;
use sc_client::Client;
use sp_consensus::import_queue::{IncomingBlock, Link, BlockImportError, BlockImportResult, ImportQueue};
use sp_consensus::BlockOrigin;
use std::{
io::{Read, Write, Seek},
};
use network::message;
use sc_network::message;
/// Build a chain spec json
pub fn build_spec<G, E>(spec: ChainSpec<G, E>, raw: bool) -> error::Result<String> where
@@ -58,8 +58,8 @@ impl<
TFchr, TSc, TImpQu, TFprb, TFpp, TNetP, TExPool, TRpc, Backend
> where
TBl: BlockT<Hash = <Blake2Hasher as Hasher>::Out>,
TBackend: 'static + client_api::backend::Backend<TBl, Blake2Hasher> + Send,
TExec: 'static + client::CallExecutor<TBl, Blake2Hasher> + Send + Sync + Clone,
TBackend: 'static + sc_client_api::backend::Backend<TBl, Blake2Hasher> + Send,
TExec: 'static + sc_client::CallExecutor<TBl, Blake2Hasher> + Send + Sync + Clone,
TImpQu: 'static + ImportQueue<TBl>,
TRtApi: 'static + Send + Sync,
{
+7 -7
View File
@@ -16,17 +16,17 @@
//! Service configuration.
pub use client::ExecutionStrategies;
pub use client_db::{kvdb::KeyValueDB, PruningMode};
pub use network::config::{ExtTransport, NetworkConfiguration, Roles};
pub use sc_client::ExecutionStrategies;
pub use sc_client_db::{kvdb::KeyValueDB, PruningMode};
pub use sc_network::config::{ExtTransport, NetworkConfiguration, Roles};
pub use sc_executor::WasmExecutionMethod;
use std::{path::PathBuf, net::SocketAddr, sync::Arc};
pub use txpool::txpool::Options as TransactionPoolOptions;
use chain_spec::{ChainSpec, RuntimeGenesis, Extension, NoExtension};
use primitives::crypto::Protected;
pub use sc_transaction_pool::txpool::Options as TransactionPoolOptions;
use sc_chain_spec::{ChainSpec, RuntimeGenesis, Extension, NoExtension};
use sp_core::crypto::Protected;
use target_info::Target;
use tel::TelemetryEndpoints;
use sc_telemetry::TelemetryEndpoints;
/// Service configuration.
#[derive(Clone)]
+6 -6
View File
@@ -16,9 +16,9 @@
//! Errors that can occur during the service operation.
use network;
use keystore;
use consensus_common;
use sc_network;
use sc_keystore;
use sp_consensus;
use sp_blockchain;
/// Service Result typedef.
@@ -32,11 +32,11 @@ pub enum Error {
/// IO error.
Io(std::io::Error),
/// Consensus error.
Consensus(consensus_common::Error),
Consensus(sp_consensus::Error),
/// Network error.
Network(network::error::Error),
Network(sc_network::error::Error),
/// Keystore error.
Keystore(keystore::Error),
Keystore(sc_keystore::Error),
/// Best chain selection strategy is missing.
#[display(fmt="Best chain selection strategy (SelectChain) is not provided.")]
SelectChainRequired,
+47 -47
View File
@@ -35,35 +35,35 @@ use std::time::{Duration, Instant};
use futures::sync::mpsc;
use parking_lot::Mutex;
use client::Client;
use sc_client::Client;
use exit_future::Signal;
use futures::prelude::*;
use futures03::{
future::{ready, FutureExt as _, TryFutureExt as _},
stream::{StreamExt as _, TryStreamExt as _},
};
use network::{
use sc_network::{
NetworkService, NetworkState, specialization::NetworkSpecialization,
Event, DhtEvent, PeerId, ReportHandle,
};
use log::{log, warn, debug, error, Level};
use codec::{Encode, Decode};
use primitives::{Blake2Hasher, H256};
use sp_core::{Blake2Hasher, H256};
use sp_runtime::generic::BlockId;
use sp_runtime::traits::{NumberFor, Block as BlockT};
pub use self::error::Error;
pub use self::builder::{ServiceBuilder, ServiceBuilderCommand};
pub use config::{Configuration, Roles, PruningMode};
pub use chain_spec::{ChainSpec, Properties, RuntimeGenesis, Extension as ChainSpecExtension};
pub use sc_chain_spec::{ChainSpec, Properties, RuntimeGenesis, Extension as ChainSpecExtension};
pub use sp_transaction_pool::{TransactionPool, TransactionPoolMaintainer, InPoolTransaction, error::IntoPoolError};
pub use txpool::txpool::Options as TransactionPoolOptions;
pub use client::FinalityNotifications;
pub use rpc::Metadata as RpcMetadata;
pub use sc_transaction_pool::txpool::Options as TransactionPoolOptions;
pub use sc_client::FinalityNotifications;
pub use sc_rpc::Metadata as RpcMetadata;
#[doc(hidden)]
pub use std::{ops::Deref, result::Result, sync::Arc};
#[doc(hidden)]
pub use network::{FinalityProofProvider, OnDemand, config::BoxFinalityProofRequestBuilder};
pub use sc_network::{FinalityProofProvider, OnDemand, config::BoxFinalityProofRequestBuilder};
#[doc(hidden)]
pub use futures::future::Executor;
@@ -96,12 +96,12 @@ pub struct Service<TBl, TCl, TSc, TNetStatus, TNet, TTxPool, TOc> {
/// If spawning a background task is not possible, we instead push the task into this `Vec`.
/// The elements must then be polled manually.
to_poll: Vec<Box<dyn Future<Item = (), Error = ()> + Send>>,
rpc_handlers: rpc_servers::RpcHandler<rpc::Metadata>,
rpc_handlers: sc_rpc_server::RpcHandler<sc_rpc::Metadata>,
_rpc: Box<dyn std::any::Any + Send + Sync>,
_telemetry: Option<tel::Telemetry>,
_telemetry: Option<sc_telemetry::Telemetry>,
_telemetry_on_connect_sinks: Arc<Mutex<Vec<mpsc::UnboundedSender<()>>>>,
_offchain_workers: Option<Arc<TOc>>,
keystore: keystore::KeyStorePtr,
keystore: sc_keystore::KeyStorePtr,
marker: PhantomData<TBl>,
}
@@ -145,13 +145,13 @@ pub trait AbstractService: 'static + Future<Item = (), Error = Error> +
/// Type of block of this chain.
type Block: BlockT<Hash = H256>;
/// Backend storage for the client.
type Backend: 'static + client_api::backend::Backend<Self::Block, Blake2Hasher>;
type Backend: 'static + sc_client_api::backend::Backend<Self::Block, Blake2Hasher>;
/// How to execute calls towards the runtime.
type CallExecutor: 'static + client::CallExecutor<Self::Block, Blake2Hasher> + Send + Sync + Clone;
type CallExecutor: 'static + sc_client::CallExecutor<Self::Block, Blake2Hasher> + Send + Sync + Clone;
/// API that the runtime provides.
type RuntimeApi: Send + Sync;
/// Chain selection algorithm.
type SelectChain: consensus_common::SelectChain<Self::Block>;
type SelectChain: sp_consensus::SelectChain<Self::Block>;
/// Transaction pool.
type TransactionPool: TransactionPool<Block = Self::Block>
+ TransactionPoolMaintainer<Block = Self::Block>;
@@ -162,7 +162,7 @@ pub trait AbstractService: 'static + Future<Item = (), Error = Error> +
fn telemetry_on_connect_stream(&self) -> mpsc::UnboundedReceiver<()>;
/// return a shared instance of Telemetry (if enabled)
fn telemetry(&self) -> Option<tel::Telemetry>;
fn telemetry(&self) -> Option<sc_telemetry::Telemetry>;
/// Spawns a task in the background that runs the future passed as parameter.
fn spawn_task(&self, task: impl Future<Item = (), Error = ()> + Send + 'static);
@@ -176,7 +176,7 @@ pub trait AbstractService: 'static + Future<Item = (), Error = Error> +
fn spawn_task_handle(&self) -> SpawnTaskHandle;
/// Returns the keystore that stores keys.
fn keystore(&self) -> keystore::KeyStorePtr;
fn keystore(&self) -> sc_keystore::KeyStorePtr;
/// Starts an RPC query.
///
@@ -190,7 +190,7 @@ pub trait AbstractService: 'static + Future<Item = (), Error = Error> +
fn rpc_query(&self, mem: &RpcSession, request: &str) -> Box<dyn Future<Item = Option<String>, Error = ()> + Send>;
/// Get shared client instance.
fn client(&self) -> Arc<client::Client<Self::Backend, Self::CallExecutor, Self::Block, Self::RuntimeApi>>;
fn client(&self) -> Arc<sc_client::Client<Self::Backend, Self::CallExecutor, Self::Block, Self::RuntimeApi>>;
/// Get clone of select chain.
fn select_chain(&self) -> Option<Self::SelectChain>;
@@ -213,10 +213,10 @@ impl<TBl, TBackend, TExec, TRtApi, TSc, TNetSpec, TExPool, TOc> AbstractService
NetworkService<TBl, TNetSpec, H256>, TExPool, TOc>
where
TBl: BlockT<Hash = H256>,
TBackend: 'static + client_api::backend::Backend<TBl, Blake2Hasher>,
TExec: 'static + client::CallExecutor<TBl, Blake2Hasher> + Send + Sync + Clone,
TBackend: 'static + sc_client_api::backend::Backend<TBl, Blake2Hasher>,
TExec: 'static + sc_client::CallExecutor<TBl, Blake2Hasher> + Send + Sync + Clone,
TRtApi: 'static + Send + Sync,
TSc: consensus_common::SelectChain<TBl> + 'static + Clone + Send,
TSc: sp_consensus::SelectChain<TBl> + 'static + Clone + Send,
TExPool: 'static + TransactionPool<Block = TBl>
+ TransactionPoolMaintainer<Block = TBl>,
TOc: 'static + Send + Sync,
@@ -236,11 +236,11 @@ where
stream
}
fn telemetry(&self) -> Option<tel::Telemetry> {
fn telemetry(&self) -> Option<sc_telemetry::Telemetry> {
self._telemetry.as_ref().map(|t| t.clone())
}
fn keystore(&self) -> keystore::KeyStorePtr {
fn keystore(&self) -> sc_keystore::KeyStorePtr {
self.keystore.clone()
}
@@ -276,7 +276,7 @@ where
Box::new(self.rpc_handlers.handle_request(request, mem.metadata.clone()))
}
fn client(&self) -> Arc<client::Client<Self::Backend, Self::CallExecutor, Self::Block, Self::RuntimeApi>> {
fn client(&self) -> Arc<sc_client::Client<Self::Backend, Self::CallExecutor, Self::Block, Self::RuntimeApi>> {
self.client.clone()
}
@@ -362,15 +362,15 @@ impl<TBl, TCl, TSc, TNetStatus, TNet, TTxPool, TOc> Executor<Box<dyn Future<Item
/// The `status_sink` contain a list of senders to send a periodic network status to.
fn build_network_future<
B: BlockT,
C: client::BlockchainEvents<B>,
S: network::specialization::NetworkSpecialization<B>,
H: network::ExHashT
C: sc_client::BlockchainEvents<B>,
S: sc_network::specialization::NetworkSpecialization<B>,
H: sc_network::ExHashT
> (
roles: Roles,
mut network: network::NetworkWorker<B, S, H>,
mut network: sc_network::NetworkWorker<B, S, H>,
client: Arc<C>,
status_sinks: Arc<Mutex<status_sinks::StatusSinks<(NetworkStatus<B>, NetworkState)>>>,
rpc_rx: futures03::channel::mpsc::UnboundedReceiver<rpc::system::Request<B>>,
rpc_rx: futures03::channel::mpsc::UnboundedReceiver<sc_rpc::system::Request<B>>,
should_have_peers: bool,
dht_event_tx: Option<mpsc::Sender<DhtEvent>>,
) -> impl Future<Item = (), Error = ()> {
@@ -406,16 +406,16 @@ fn build_network_future<
// Poll the RPC requests and answer them.
while let Ok(Async::Ready(Some(request))) = rpc_rx.poll() {
match request {
rpc::system::Request::Health(sender) => {
let _ = sender.send(rpc::system::Health {
sc_rpc::system::Request::Health(sender) => {
let _ = sender.send(sc_rpc::system::Health {
peers: network.peers_debug_info().len(),
is_syncing: network.service().is_major_syncing(),
should_have_peers,
});
},
rpc::system::Request::Peers(sender) => {
sc_rpc::system::Request::Peers(sender) => {
let _ = sender.send(network.peers_debug_info().into_iter().map(|(peer_id, p)|
rpc::system::PeerInfo {
sc_rpc::system::PeerInfo {
peer_id: peer_id.to_base58(),
roles: format!("{:?}", p.roles),
protocol_version: p.protocol_version,
@@ -424,13 +424,13 @@ fn build_network_future<
}
).collect());
}
rpc::system::Request::NetworkState(sender) => {
sc_rpc::system::Request::NetworkState(sender) => {
if let Some(network_state) = serde_json::to_value(&network.network_state()).ok() {
let _ = sender.send(network_state);
}
}
rpc::system::Request::NodeRoles(sender) => {
use rpc::system::NodeRole;
sc_rpc::system::Request::NodeRoles(sender) => {
use sc_rpc::system::NodeRole;
let node_roles = (0 .. 8)
.filter(|&bit_number| (roles.bits() >> bit_number) & 1 == 1)
@@ -506,7 +506,7 @@ fn build_network_future<
#[derive(Clone)]
pub struct NetworkStatus<B: BlockT> {
/// Current global sync state.
pub sync_state: network::SyncState,
pub sync_state: sc_network::SyncState,
/// Target sync block number.
pub best_seen_block: Option<NumberFor<B>>,
/// Number of peers participating in syncing.
@@ -534,7 +534,7 @@ impl<TBl, TCl, TSc, TNetStatus, TNet, TTxPool, TOc> Drop for
/// Starts RPC servers that run in their own thread, and returns an opaque object that keeps them alive.
#[cfg(not(target_os = "unknown"))]
fn start_rpc_servers<C, G, E, H: FnMut() -> rpc_servers::RpcHandler<rpc::Metadata>>(
fn start_rpc_servers<C, G, E, H: FnMut() -> sc_rpc_server::RpcHandler<sc_rpc::Metadata>>(
config: &Configuration<C, G, E>,
mut gen_handler: H
) -> Result<Box<dyn std::any::Any + Send + Sync>, error::Error> {
@@ -559,11 +559,11 @@ fn start_rpc_servers<C, G, E, H: FnMut() -> rpc_servers::RpcHandler<rpc::Metadat
Ok(Box::new((
maybe_start_server(
config.rpc_http,
|address| rpc_servers::start_http(address, config.rpc_cors.as_ref(), gen_handler()),
|address| sc_rpc_server::start_http(address, config.rpc_cors.as_ref(), gen_handler()),
)?,
maybe_start_server(
config.rpc_ws,
|address| rpc_servers::start_ws(
|address| sc_rpc_server::start_ws(
address,
config.rpc_ws_max_connections,
config.rpc_cors.as_ref(),
@@ -575,7 +575,7 @@ fn start_rpc_servers<C, G, E, H: FnMut() -> rpc_servers::RpcHandler<rpc::Metadat
/// Starts RPC servers that run in their own thread, and returns an opaque object that keeps them alive.
#[cfg(target_os = "unknown")]
fn start_rpc_servers<C, G, E, H: FnMut() -> rpc_servers::RpcHandler<rpc::Metadata>>(
fn start_rpc_servers<C, G, E, H: FnMut() -> sc_rpc_server::RpcHandler<sc_rpc::Metadata>>(
_: &Configuration<C, G, E>,
_: H
) -> Result<Box<dyn std::any::Any + Send + Sync>, error::Error> {
@@ -586,7 +586,7 @@ fn start_rpc_servers<C, G, E, H: FnMut() -> rpc_servers::RpcHandler<rpc::Metadat
/// the HTTP or WebSockets server).
#[derive(Clone)]
pub struct RpcSession {
metadata: rpc::Metadata,
metadata: sc_rpc::Metadata,
}
impl RpcSession {
@@ -632,10 +632,10 @@ where
.collect()
}
impl<B, H, C, Pool, E> network::TransactionPool<H, B> for
impl<B, H, C, Pool, E> sc_network::TransactionPool<H, B> for
TransactionPoolAdapter<C, Pool>
where
C: network::ClientHandle<B> + Send + Sync,
C: sc_network::ClientHandle<B> + Send + Sync,
Pool: 'static + TransactionPool<Block=B, Hash=H, Error=E>,
B: BlockT,
H: std::hash::Hash + Eq + sp_runtime::traits::Member + sp_runtime::traits::MaybeSerialize,
@@ -653,8 +653,8 @@ where
&self,
report_handle: ReportHandle,
who: PeerId,
reputation_change_good: network::ReputationChange,
reputation_change_bad: network::ReputationChange,
reputation_change_good: sc_network::ReputationChange,
reputation_change_bad: sc_network::ReputationChange,
transaction: B::Extrinsic
) {
if !self.imports_external_transactions {
@@ -701,10 +701,10 @@ where
mod tests {
use super::*;
use futures03::executor::block_on;
use consensus_common::SelectChain;
use sp_consensus::SelectChain;
use sp_runtime::traits::BlindCheckable;
use substrate_test_runtime_client::{prelude::*, runtime::{Extrinsic, Transfer}};
use txpool::{BasicPool, FullChainApi};
use sc_transaction_pool::{BasicPool, FullChainApi};
#[test]
fn should_not_propagate_transactions_that_are_marked_as_such() {