ChainSpec trait (#5185)

* ChainSpec trait

* Apply suggestions from code review

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Added docs

* Fixed build

* Fixed build

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Arkadiy Paronyan
2020-03-12 00:00:10 +01:00
committed by GitHub
parent d2345e8d5c
commit dc0bf210fb
38 changed files with 354 additions and 335 deletions
+7 -13
View File
@@ -25,9 +25,7 @@ mod purge_chain_cmd;
use std::fmt::Debug;
use structopt::StructOpt;
use sc_service::{
Configuration, ChainSpecExtension, RuntimeGenesis, ServiceBuilderCommand, ChainSpec,
};
use sc_service::{ Configuration, ServiceBuilderCommand, ChainSpec };
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
use crate::error;
@@ -87,15 +85,13 @@ impl Subcommand {
}
/// Run any `CoreParams` command
pub fn run<G, E, B, BC, BB>(
pub fn run<B, BC, BB>(
self,
config: Configuration<G, E>,
config: Configuration,
builder: B,
) -> error::Result<()>
where
B: FnOnce(Configuration<G, E>) -> Result<BC, sc_service::error::Error>,
G: RuntimeGenesis,
E: ChainSpecExtension,
B: FnOnce(Configuration) -> Result<BC, sc_service::error::Error>,
BC: ServiceBuilderCommand<Block = BB> + Unpin,
BB: sp_runtime::traits::Block + Debug,
<<<BB as BlockT>::Header as HeaderT>::Number as std::str::FromStr>::Err: std::fmt::Debug,
@@ -112,15 +108,13 @@ impl Subcommand {
}
/// Update and prepare a `Configuration` with command line parameters
pub fn update_config<G, E, F>(
pub fn update_config<F>(
&self,
mut config: &mut Configuration<G, E>,
mut config: &mut Configuration,
spec_factory: F,
version: &VersionInfo,
) -> error::Result<()> where
G: RuntimeGenesis,
E: ChainSpecExtension,
F: FnOnce(&str) -> Result<Option<ChainSpec<G, E>>, String>,
F: FnOnce(&str) -> Result<Box<dyn ChainSpec>, String>,
{
match self {
Subcommand::BuildSpec(cmd) => cmd.update_config(&mut config, spec_factory, version),