Remove the service builder (#6557)

* :)

* Slight tidy

* Remove ServiceBuilderCommand

* Remove whitespace

* Keep task manager alive for check_block/import_blocks

* Pass task_manager to run_until_exit

* WIP

* WIP

* Get rid of the macros

* Simplify a few chain components creation APIs related to the service

* Fix basic-authorship doc tests

* Remove DefaultQueue

* Update client/service/src/builder.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Move ExecutionExtensions comment around

* Remove unused BlakeTwo256

* Add sc-prelude

* Rename sc-prelude to sc-service-prelude

* Rename to sc-service-types

* Improve service types

* Fix line widths

* Remove sc-service-types and move type definitions to crates

* Update bin/node-template/node/src/service.rs

Co-authored-by: Seun Lanlege <seunlanlege@gmail.com>

* Add TLightClientWithHash

* Rework types

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
Co-authored-by: Seun Lanlege <seunlanlege@gmail.com>
This commit is contained in:
Ashley
2020-07-22 21:10:27 +02:00
committed by GitHub
parent 85a9af64d8
commit ffa2177d46
12 changed files with 706 additions and 1272 deletions
+2 -2
View File
@@ -714,7 +714,7 @@ fn authorities<A, B, C>(client: &C, at: &BlockId<B>) -> Result<Vec<A>, Consensus
}
/// The Aura import queue type.
pub type AuraImportQueue<B, Transaction> = BasicQueue<B, Transaction>;
pub type AuraImportQueue<B, Client> = BasicQueue<B, sp_api::TransactionFor<Client, B>>;
/// Register the aura inherent data provider, if not registered already.
fn register_aura_inherent_data_provider(
@@ -824,7 +824,7 @@ pub fn import_queue<B, I, C, P, S>(
inherent_data_providers: InherentDataProviders,
spawner: &S,
registry: Option<&Registry>,
) -> Result<AuraImportQueue<B, sp_api::TransactionFor<C, B>>, sp_consensus::Error> where
) -> Result<AuraImportQueue<B, C>, sp_consensus::Error> where
B: BlockT,
C::Api: BlockBuilderApi<B> + AuraApi<B, AuthorityId<P>> + ApiExt<B, Error = sp_blockchain::Error>,
C: 'static + ProvideRuntimeApi<B> + BlockOf + ProvideCache<B> + Send + Sync + AuxStore + HeaderBackend<B>,
+2 -2
View File
@@ -968,7 +968,7 @@ where
}
/// The BABE import queue type.
pub type BabeImportQueue<B, Transaction> = BasicQueue<B, Transaction>;
pub type BabeImportQueue<B, Client> = BasicQueue<B, sp_api::TransactionFor<Client, B>>;
/// Register the babe inherent data provider, if not registered already.
fn register_babe_inherent_data_provider(
@@ -1368,7 +1368,7 @@ pub fn import_queue<Block: BlockT, Client, SelectChain, Inner>(
inherent_data_providers: InherentDataProviders,
spawner: &impl sp_core::traits::SpawnNamed,
registry: Option<&Registry>,
) -> ClientResult<BabeImportQueue<Block, sp_api::TransactionFor<Client, Block>>> where
) -> ClientResult<BabeImportQueue<Block, Client>> where
Inner: BlockImport<Block, Error = ConsensusError, Transaction = sp_api::TransactionFor<Client, Block>>
+ Send + Sync + 'static,
Client: ProvideRuntimeApi<Block> + ProvideCache<Block> + Send + Sync + AuxStore + 'static,
File diff suppressed because it is too large Load Diff
+5 -14
View File
@@ -52,9 +52,10 @@ use sp_utils::{status_sinks, mpsc::{tracing_unbounded, TracingUnboundedReceiver,
pub use self::error::Error;
pub use self::builder::{
new_full_client, new_client,
ServiceBuilder, TFullClient, TLightClient, TFullBackend, TLightBackend,
TFullCallExecutor, TLightCallExecutor, RpcExtensionBuilder,
new_full_client, new_client, new_full_parts, new_light_parts, build,
ServiceParams, TFullClient, TLightClient, TFullBackend, TLightBackend,
TLightBackendWithHash, TLightClientWithBackend,
TFullCallExecutor, TLightCallExecutor, RpcExtensionBuilder, NoopRpcExtensionBuilder,
};
pub use config::{
BasePath, Configuration, DatabaseConfig, PruningMode, Role, RpcMethods, TaskExecutor, TaskType,
@@ -150,25 +151,15 @@ impl TelemetryOnConnectSinks {
/// The individual components of the chain, built by the service builder. You are encouraged to
/// deconstruct this into its fields.
pub struct ServiceComponents<TBl: BlockT, TBackend: Backend<TBl>, TSc, TExPool, TCl> {
/// A blockchain client.
pub client: Arc<TCl>,
/// A shared transaction pool instance.
pub transaction_pool: Arc<TExPool>,
pub struct ServiceComponents<TBl: BlockT, TBackend: Backend<TBl>, TCl> {
/// The chain task manager.
pub task_manager: TaskManager,
/// A keystore that stores keys.
pub keystore: sc_keystore::KeyStorePtr,
/// A shared network instance.
pub network: Arc<sc_network::NetworkService<TBl, <TBl as BlockT>::Hash>>,
/// RPC handlers that can perform RPC queries.
pub rpc_handlers: Arc<RpcHandlers>,
/// A shared instance of the chain selection algorithm.
pub select_chain: Option<TSc>,
/// Sinks to propagate network status updates.
pub network_status_sinks: NetworkStatusSinks<TBl>,
/// A prometheus metrics registry, (if enabled).
pub prometheus_registry: Option<prometheus_endpoint::Registry>,
/// Shared Telemetry connection sinks,
pub telemetry_on_connect_sinks: TelemetryOnConnectSinks,
/// A shared offchain workers instance.
@@ -64,6 +64,11 @@ type ReadyIteratorFor<PoolApi> = BoxedReadyIterator<
type PolledIterator<PoolApi> = Pin<Box<dyn Future<Output=ReadyIteratorFor<PoolApi>> + Send>>;
/// A transaction pool for a full node.
pub type FullPool<Block, Client> = BasicPool<FullChainApi<Client, Block>, Block>;
/// A transaction pool for a light node.
pub type LightPool<Block, Client, Fetcher> = BasicPool<LightChainApi<Client, Fetcher, Block>, Block>;
/// Basic implementation of transaction pool that can be customized by providing PoolApi.
pub struct BasicPool<PoolApi, Block>
where