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:
Squirrel
2024-01-01 22:46:44 +00:00
committed by GitHub
parent 9a27b53e8e
commit 1dd1a16066
6 changed files with 75 additions and 71 deletions
+11 -11
View File
@@ -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.
///
/// 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(
config: &mut Configuration,
enable_import_proof_record: bool,
) -> Result<
PartialComponents<
Client,
Backend,
(),
sc_consensus::import_queue::BasicQueue<Block>,
sc_transaction_pool::FullPool<Block, Client>,
ParachainBlockImport,
>,
sc_service::Error,
> {
) -> Result<Service, sc_service::Error> {
let heap_pages = config
.default_heap_pages
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _ });