mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 12:11:09 +00:00
Extract PartialComponents into a type alias (#2767)
Pulling PartialComponents into a named `Service` type stops clippy complaining about type complexity and also makes the type signatures a little less scary to read. There's two instances where we can't pull it out into a type because a nightly feature has not yet been stabilised (E.g. the `imp Fn` isn't stabilised in a type alias context here: https://github.com/paritytech/polkadot-sdk/blob/d84e135bbfc366a17bb6b72d0fc9d09ee781ab8d/polkadot/node/service/src/lib.rs#L477 ). --------- Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -59,23 +59,21 @@ type ParachainBackend = TFullBackend<Block>;
|
|||||||
|
|
||||||
type ParachainBlockImport = TParachainBlockImport<Block, Arc<ParachainClient>, ParachainBackend>;
|
type ParachainBlockImport = TParachainBlockImport<Block, Arc<ParachainClient>, ParachainBackend>;
|
||||||
|
|
||||||
|
/// Assembly of PartialComponents (enough to run chain ops subcommands)
|
||||||
|
pub type Service = PartialComponents<
|
||||||
|
ParachainClient,
|
||||||
|
ParachainBackend,
|
||||||
|
(),
|
||||||
|
sc_consensus::DefaultImportQueue<Block>,
|
||||||
|
sc_transaction_pool::FullPool<Block, ParachainClient>,
|
||||||
|
(ParachainBlockImport, Option<Telemetry>, Option<TelemetryWorkerHandle>),
|
||||||
|
>;
|
||||||
|
|
||||||
/// Starts a `ServiceBuilder` for a full service.
|
/// Starts a `ServiceBuilder` for a full service.
|
||||||
///
|
///
|
||||||
/// Use this macro if you don't actually need the full service, but just the builder in order to
|
/// Use this macro if you don't actually need the full service, but just the builder in order to
|
||||||
/// be able to perform chain operations.
|
/// be able to perform chain operations.
|
||||||
pub fn new_partial(
|
pub fn new_partial(config: &Configuration) -> Result<Service, sc_service::Error> {
|
||||||
config: &Configuration,
|
|
||||||
) -> Result<
|
|
||||||
PartialComponents<
|
|
||||||
ParachainClient,
|
|
||||||
ParachainBackend,
|
|
||||||
(),
|
|
||||||
sc_consensus::DefaultImportQueue<Block>,
|
|
||||||
sc_transaction_pool::FullPool<Block, ParachainClient>,
|
|
||||||
(ParachainBlockImport, Option<Telemetry>, Option<TelemetryWorkerHandle>),
|
|
||||||
>,
|
|
||||||
sc_service::Error,
|
|
||||||
> {
|
|
||||||
let telemetry = config
|
let telemetry = config
|
||||||
.telemetry_endpoints
|
.telemetry_endpoints
|
||||||
.clone()
|
.clone()
|
||||||
|
|||||||
@@ -216,6 +216,16 @@ impl sc_executor::NativeExecutionDispatch for PeopleRococoRuntimeExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Assembly of PartialComponents (enough to run chain ops subcommands)
|
||||||
|
pub type Service<RuntimeApi> = PartialComponents<
|
||||||
|
ParachainClient<RuntimeApi>,
|
||||||
|
ParachainBackend,
|
||||||
|
(),
|
||||||
|
sc_consensus::DefaultImportQueue<Block>,
|
||||||
|
sc_transaction_pool::FullPool<Block, ParachainClient<RuntimeApi>>,
|
||||||
|
(ParachainBlockImport<RuntimeApi>, Option<Telemetry>, Option<TelemetryWorkerHandle>),
|
||||||
|
>;
|
||||||
|
|
||||||
/// Starts a `ServiceBuilder` for a full service.
|
/// Starts a `ServiceBuilder` for a full service.
|
||||||
///
|
///
|
||||||
/// Use this macro if you don't actually need the full service, but just the builder in order to
|
/// Use this macro if you don't actually need the full service, but just the builder in order to
|
||||||
@@ -223,17 +233,7 @@ impl sc_executor::NativeExecutionDispatch for PeopleRococoRuntimeExecutor {
|
|||||||
pub fn new_partial<RuntimeApi, BIQ>(
|
pub fn new_partial<RuntimeApi, BIQ>(
|
||||||
config: &Configuration,
|
config: &Configuration,
|
||||||
build_import_queue: BIQ,
|
build_import_queue: BIQ,
|
||||||
) -> Result<
|
) -> Result<Service<RuntimeApi>, sc_service::Error>
|
||||||
PartialComponents<
|
|
||||||
ParachainClient<RuntimeApi>,
|
|
||||||
ParachainBackend,
|
|
||||||
(),
|
|
||||||
sc_consensus::DefaultImportQueue<Block>,
|
|
||||||
sc_transaction_pool::FullPool<Block, ParachainClient<RuntimeApi>>,
|
|
||||||
(ParachainBlockImport<RuntimeApi>, Option<Telemetry>, Option<TelemetryWorkerHandle>),
|
|
||||||
>,
|
|
||||||
sc_service::Error,
|
|
||||||
>
|
|
||||||
where
|
where
|
||||||
RuntimeApi: ConstructRuntimeApi<Block, ParachainClient<RuntimeApi>> + Send + Sync + 'static,
|
RuntimeApi: ConstructRuntimeApi<Block, ParachainClient<RuntimeApi>> + Send + Sync + 'static,
|
||||||
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
|
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
|
||||||
|
|||||||
@@ -183,6 +183,16 @@ impl RecoveryHandle for FailingRecoveryHandle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Assembly of PartialComponents (enough to run chain ops subcommands)
|
||||||
|
pub type Service = PartialComponents<
|
||||||
|
Client,
|
||||||
|
Backend,
|
||||||
|
(),
|
||||||
|
sc_consensus::import_queue::BasicQueue<Block>,
|
||||||
|
sc_transaction_pool::FullPool<Block, Client>,
|
||||||
|
ParachainBlockImport,
|
||||||
|
>;
|
||||||
|
|
||||||
/// Starts a `ServiceBuilder` for a full service.
|
/// Starts a `ServiceBuilder` for a full service.
|
||||||
///
|
///
|
||||||
/// Use this macro if you don't actually need the full service, but just the builder in order to
|
/// Use this macro if you don't actually need the full service, but just the builder in order to
|
||||||
@@ -190,17 +200,7 @@ impl RecoveryHandle for FailingRecoveryHandle {
|
|||||||
pub fn new_partial(
|
pub fn new_partial(
|
||||||
config: &mut Configuration,
|
config: &mut Configuration,
|
||||||
enable_import_proof_record: bool,
|
enable_import_proof_record: bool,
|
||||||
) -> Result<
|
) -> Result<Service, sc_service::Error> {
|
||||||
PartialComponents<
|
|
||||||
Client,
|
|
||||||
Backend,
|
|
||||||
(),
|
|
||||||
sc_consensus::import_queue::BasicQueue<Block>,
|
|
||||||
sc_transaction_pool::FullPool<Block, Client>,
|
|
||||||
ParachainBlockImport,
|
|
||||||
>,
|
|
||||||
sc_service::Error,
|
|
||||||
> {
|
|
||||||
let heap_pages = config
|
let heap_pages = config
|
||||||
.default_heap_pages
|
.default_heap_pages
|
||||||
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _ });
|
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _ });
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
|
||||||
|
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json
|
||||||
|
|
||||||
|
title: Extract PartialComponents into type alias `Service`
|
||||||
|
|
||||||
|
doc:
|
||||||
|
- audience: Node Dev
|
||||||
|
description: |
|
||||||
|
Simplifies service definitions by extraction of a complicated type into a type alias. No breaking changes.
|
||||||
|
|
||||||
|
crates:
|
||||||
|
- name: "sc-service"
|
||||||
|
- name: "node-template"
|
||||||
|
- name: "minimal-node"
|
||||||
|
- name: "cumulus-test-service"
|
||||||
|
- name: "polkadot-parachain-bin"
|
||||||
|
- name: "parachain-template-node"
|
||||||
@@ -38,19 +38,17 @@ pub(crate) type FullClient =
|
|||||||
type FullBackend = sc_service::TFullBackend<Block>;
|
type FullBackend = sc_service::TFullBackend<Block>;
|
||||||
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
||||||
|
|
||||||
pub fn new_partial(
|
/// Assembly of PartialComponents (enough to run chain ops subcommands)
|
||||||
config: &Configuration,
|
pub type Service = sc_service::PartialComponents<
|
||||||
) -> Result<
|
FullClient,
|
||||||
sc_service::PartialComponents<
|
FullBackend,
|
||||||
FullClient,
|
FullSelectChain,
|
||||||
FullBackend,
|
sc_consensus::DefaultImportQueue<Block>,
|
||||||
FullSelectChain,
|
sc_transaction_pool::FullPool<Block, FullClient>,
|
||||||
sc_consensus::DefaultImportQueue<Block>,
|
Option<Telemetry>,
|
||||||
sc_transaction_pool::FullPool<Block, FullClient>,
|
>;
|
||||||
Option<Telemetry>,
|
|
||||||
>,
|
pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
|
||||||
ServiceError,
|
|
||||||
> {
|
|
||||||
let telemetry = config
|
let telemetry = config
|
||||||
.telemetry_endpoints
|
.telemetry_endpoints
|
||||||
.clone()
|
.clone()
|
||||||
|
|||||||
@@ -23,29 +23,20 @@ type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
|||||||
/// imported and generated.
|
/// imported and generated.
|
||||||
const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512;
|
const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512;
|
||||||
|
|
||||||
#[allow(clippy::type_complexity)]
|
pub type Service = sc_service::PartialComponents<
|
||||||
pub fn new_partial(
|
FullClient,
|
||||||
config: &Configuration,
|
FullBackend,
|
||||||
) -> Result<
|
FullSelectChain,
|
||||||
sc_service::PartialComponents<
|
sc_consensus::DefaultImportQueue<Block>,
|
||||||
FullClient,
|
sc_transaction_pool::FullPool<Block, FullClient>,
|
||||||
FullBackend,
|
(
|
||||||
FullSelectChain,
|
sc_consensus_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>,
|
||||||
sc_consensus::DefaultImportQueue<Block>,
|
sc_consensus_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
|
||||||
sc_transaction_pool::FullPool<Block, FullClient>,
|
Option<Telemetry>,
|
||||||
(
|
),
|
||||||
sc_consensus_grandpa::GrandpaBlockImport<
|
>;
|
||||||
FullBackend,
|
|
||||||
Block,
|
pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
|
||||||
FullClient,
|
|
||||||
FullSelectChain,
|
|
||||||
>,
|
|
||||||
sc_consensus_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
|
|
||||||
Option<Telemetry>,
|
|
||||||
),
|
|
||||||
>,
|
|
||||||
ServiceError,
|
|
||||||
> {
|
|
||||||
let telemetry = config
|
let telemetry = config
|
||||||
.telemetry_endpoints
|
.telemetry_endpoints
|
||||||
.clone()
|
.clone()
|
||||||
|
|||||||
Reference in New Issue
Block a user