Skip to content

Commit

Permalink
Extract PartialComponents into a type alias (paritytech#2767)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
gilescope and bkchr authored Jan 1, 2024
1 parent e26fac5 commit e3b824c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 36 deletions.
24 changes: 11 additions & 13 deletions substrate/bin/minimal/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,17 @@ pub(crate) type FullClient =
type FullBackend = sc_service::TFullBackend<Block>;
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;

pub fn new_partial(
config: &Configuration,
) -> Result<
sc_service::PartialComponents<
FullClient,
FullBackend,
FullSelectChain,
sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::FullPool<Block, FullClient>,
Option<Telemetry>,
>,
ServiceError,
> {
/// Assembly of PartialComponents (enough to run chain ops subcommands)
pub type Service = sc_service::PartialComponents<
FullClient,
FullBackend,
FullSelectChain,
sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::FullPool<Block, FullClient>,
Option<Telemetry>,
>;

pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
let telemetry = config
.telemetry_endpoints
.clone()
Expand Down
37 changes: 14 additions & 23 deletions substrate/bin/node-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,20 @@ type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
/// imported and generated.
const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512;

#[allow(clippy::type_complexity)]
pub fn new_partial(
config: &Configuration,
) -> Result<
sc_service::PartialComponents<
FullClient,
FullBackend,
FullSelectChain,
sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::FullPool<Block, FullClient>,
(
sc_consensus_grandpa::GrandpaBlockImport<
FullBackend,
Block,
FullClient,
FullSelectChain,
>,
sc_consensus_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
Option<Telemetry>,
),
>,
ServiceError,
> {
pub type Service = sc_service::PartialComponents<
FullClient,
FullBackend,
FullSelectChain,
sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::FullPool<Block, FullClient>,
(
sc_consensus_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>,
sc_consensus_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
Option<Telemetry>,
),
>;

pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
let telemetry = config
.telemetry_endpoints
.clone()
Expand Down

0 comments on commit e3b824c

Please sign in to comment.