pub fn run() -> sc_cli::Result<()> {
	let cli = Cli::from_args();

	match &cli.subcommand {
		Some(Subcommand::Key(cmd)) => cmd.run(&cli),
		Some(Subcommand::BuildSpec(cmd)) => {
			let runner = cli.create_runner(cmd)?;
			runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
		}
		Some(Subcommand::CheckBlock(cmd)) => {
			let runner = cli.create_runner(cmd)?;
			runner.async_run(|config| {
				let PartialComponents {
					client,
					task_manager,
					import_queue,
					..
				} = service::new_partial(&config, &cli)?;
				Ok((cmd.run(client, import_queue), task_manager))
			})
		}
		Some(Subcommand::ExportBlocks(cmd)) => {
			let runner = cli.create_runner(cmd)?;
			runner.async_run(|config| {
				let PartialComponents {
					client,
					task_manager,
					..
				} = service::new_partial(&config, &cli)?;
				Ok((cmd.run(client, config.database), task_manager))
			})
		}
		Some(Subcommand::ExportState(cmd)) => {
			let runner = cli.create_runner(cmd)?;
			runner.async_run(|config| {
				let PartialComponents {
					client,
					task_manager,
					..
				} = service::new_partial(&config, &cli)?;
				Ok((cmd.run(client, config.chain_spec), task_manager))
			})
		}
		Some(Subcommand::ImportBlocks(cmd)) => {
			let runner = cli.create_runner(cmd)?;
			runner.async_run(|config| {
				let PartialComponents {
					client,
					task_manager,
					import_queue,
					..
				} = service::new_partial(&config, &cli)?;
				Ok((cmd.run(client, import_queue), task_manager))
			})
		}
		Some(Subcommand::PurgeChain(cmd)) => {
			let runner = cli.create_runner(cmd)?;
			runner.sync_run(|config| {
				// Remove Frontier offchain db
				let frontier_database_config = sc_service::DatabaseSource::RocksDb {
					path: frontier_database_dir(&config),
					cache_size: 0,
				};
				cmd.run(frontier_database_config)?;
				cmd.run(config.database)
			})
		}
		Some(Subcommand::Revert(cmd)) => {
			let runner = cli.create_runner(cmd)?;
			runner.async_run(|config| {
				let PartialComponents {
					client,
					task_manager,
					backend,
					..
				} = service::new_partial(&config, &cli)?;
				Ok((cmd.run(client, backend), task_manager))
			})
		}
		Some(Subcommand::Benchmark(cmd)) => {
			if cfg!(feature = "runtime-benchmarks") {
				let runner = cli.create_runner(cmd)?;

				runner.sync_run(|config| cmd.run::<Block, service::Executor>(config))
			} else {
				Err(
					"Benchmarking wasn't enabled when building the node. You can enable it with `--features runtime-benchmarks`."
						.into(),
				)
			}
		}
		None => {
			let runner = cli.create_runner(&cli.run.base)?;
			runner.run_node_until_exit(|config| async move {
				match config.role {
					// NOTE: light client removed, you may configure other roles here
					// you will need `use sc_cli::Role;` added
					// Role::Light => service::new_light(config), 
					_ => service::new_full(config, &cli),
				}
				.map_err(sc_cli::Error::Service)
			})
		}
	}
}
/// Parse and run command line arguments
Parse and run command line arguments
Parse and run command line arguments
pub fn run() -> sc_cli::Result<()> {
	let cli = Cli::from_args();
	match &cli.subcommand {
		Some(Subcommand::Key(cmd)) => cmd.run(&cli),
		Some(Subcommand::BuildSpec(cmd)) => {
			let runner = cli.create_runner(cmd)?;
			runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
		}
		Some(Subcommand::CheckBlock(cmd)) => {
			let runner = cli.create_runner(cmd)?;
			runner.async_run(|config| {
				let PartialComponents {
					client,
					task_manager,
					import_queue,
					..
				} = service::new_partial(&config, &cli)?;
				Ok((cmd.run(client, import_queue), task_manager))
			})
		}
		Some(Subcommand::ExportBlocks(cmd)) => {
			let runner = cli.create_runner(cmd)?;
			runner.async_run(|config| {
				let PartialComponents {
					client,
					task_manager,
					..
				} = service::new_partial(&config, &cli)?;
				Ok((cmd.run(client, config.database), task_manager))
			})
		}
		Some(Subcommand::ExportState(cmd)) => {
			let runner = cli.create_runner(cmd)?;
			runner.async_run(|config| {
				let PartialComponents {
					client,
					task_manager,
					..
				} = service::new_partial(&config, &cli)?;
				Ok((cmd.run(client, config.chain_spec), task_manager))
			})
		}
		Some(Subcommand::ImportBlocks(cmd)) => {
			let runner = cli.create_runner(cmd)?;
			runner.async_run(|config| {
				let PartialComponents {
					client,
					task_manager,
					import_queue,
					..
				} = service::new_partial(&config, &cli)?;
				Ok((cmd.run(client, import_queue), task_manager))
			})
		}
		Some(Subcommand::PurgeChain(cmd)) => {
			let runner = cli.create_runner(cmd)?;
			runner.sync_run(|config| {
				// Remove Frontier offchain db
				let frontier_database_config = sc_service::DatabaseSource::RocksDb {
					path: frontier_database_dir(&config),
					cache_size: 0,
				};
				cmd.run(frontier_database_config)?;
				cmd.run(config.database)
			})
		}
		Some(Subcommand::Revert(cmd)) => {
			let runner = cli.create_runner(cmd)?;
			runner.async_run(|config| {
				let PartialComponents {
					client,
					task_manager,
					backend,
					..
				} = service::new_partial(&config, &cli)?;
				Ok((cmd.run(client, backend), task_manager))
			})
		}
		Some(Subcommand::Benchmark(cmd)) => {
			if cfg!(feature = "runtime-benchmarks") {
				let runner = cli.create_runner(cmd)?;
				runner.sync_run(|config| cmd.run::<Block, service::Executor>(config))
			} else {
				Err(
					"Benchmarking wasn't enabled when building the node. You can enable it with `--features runtime-benchmarks`."
						.into(),
				)
			}
		}
		None => {
			let runner = cli.create_runner(&cli.run.base)?;
			runner.run_node_until_exit(|config| async move {
				match config.role {
					// NOTE: light client removed, you may configure other roles here
					// you will need `use sc_cli::Role;` added
					// Role::Light => service::new_light(config), 
					_ => service::new_full(config, &cli),
				}
				.map_err(sc_cli::Error::Service)
			})
		}
	}
}
pub fn run ( ) -> sc_cli :: Result < ( ) > { let cli = Cli :: from_args ( ) ; match & cli . subcommand { Some ( Subcommand :: Key ( cmd ) ) => cmd . run ( & cli ) , Some ( Subcommand :: BuildSpec ( cmd ) ) => { let runner = cli . create_runner ( cmd ) ? ; runner . sync_run ( | config | cmd . run ( config . chain_spec , config . network ) ) } Some ( Subcommand :: CheckBlock ( cmd ) ) => { let runner = cli . create_runner ( cmd ) ? ; runner . async_run ( | config | { let PartialComponents { client , task_manager , import_queue , .. } = service :: new_partial ( & config , & cli ) ? ; Ok ( ( cmd . run ( client , import_queue ) , task_manager ) ) } ) } Some ( Subcommand :: ExportBlocks ( cmd ) ) => { let runner = cli . create_runner ( cmd ) ? ; runner . async_run ( | config | { let PartialComponents { client , task_manager , .. } = service :: new_partial ( & config , & cli ) ? ; Ok ( ( cmd . run ( client , config . database ) , task_manager ) ) } ) } Some ( Subcommand :: ExportState ( cmd ) ) => { let runner = cli . create_runner ( cmd ) ? ; runner . async_run ( | config | { let PartialComponents { client , task_manager , .. } = service :: new_partial ( & config , & cli ) ? ; Ok ( ( cmd . run ( client , config . chain_spec ) , task_manager ) ) } ) } Some ( Subcommand :: ImportBlocks ( cmd ) ) => { let runner = cli . create_runner ( cmd ) ? ; runner . async_run ( | config | { let PartialComponents { client , task_manager , import_queue , .. } = service :: new_partial ( & config , & cli ) ? ; Ok ( ( cmd . run ( client , import_queue ) , task_manager ) ) } ) } Some ( Subcommand :: PurgeChain ( cmd ) ) => { let runner = cli . create_runner ( cmd ) ? ; runner . sync_run ( | config | { // Remove Frontier offchain db let frontier_database_config = sc_service :: DatabaseSource :: RocksDb { path : frontier_database_dir ( & config ) , cache_size : 0 , } ; cmd . run ( frontier_database_config ) ? ; cmd . run ( config . database ) } ) } Some ( Subcommand :: Revert ( cmd ) ) => { let runner = cli . create_runner ( cmd ) ? ; runner . async_run ( | config | { let PartialComponents { client , task_manager , backend , .. } = service :: new_partial ( & config , & cli ) ? ; Ok ( ( cmd . run ( client , backend ) , task_manager ) ) } ) } Some ( Subcommand :: Benchmark ( cmd ) ) => { if cfg ! ( feature " " ) { let runner = cli . create_runner ( cmd ) ? ; runner . sync_run ( | config | cmd . run :: < Block , service :: Executor > ( config ) ) } else { Err ( " " . into ( ) , ) } } None => { let runner = cli . create_runner ( & cli . run . base ) ? ; runner . run_node_until_exit ( | config | async move { match config . role { // NOTE: light client removed, you may configure other roles here // you will need `use sc_cli::Role;` added // Role::Light => service::new_light(config),  _ => service :: new_full ( config , & cli ) , } . map_err ( sc_cli :: Error :: Service ) } ) } } }
Parse and run command line arguments
Parse and run command line arguments