mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 04:37:57 +00:00
Remove ServiceBuilderCommand and implement the chain ops as standalone functions instead. (#6543)
* :) * Slight tidy * Remove ServiceBuilderCommand * Remove whitespace * Keep task manager alive for check_block/import_blocks * Pass task_manager to run_until_exit * Make task_manager in run_until_exit and make subcommands async * Change the async_run fn to return a future and task manager * async_run should take a result fn * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Fix spaces in export_raw_state Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -19,9 +19,9 @@
|
||||
use crate::{
|
||||
CliConfiguration, error, params::{ImportParams, SharedParams, BlockNumberOrHash},
|
||||
};
|
||||
use sc_service::{Configuration, ServiceBuilderCommand};
|
||||
use sp_runtime::traits::{Block as BlockT, NumberFor};
|
||||
use std::{fmt::Debug, str::FromStr};
|
||||
use sc_client_api::{BlockBackend, UsageProvider};
|
||||
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
|
||||
use std::{fmt::Debug, str::FromStr, sync::Arc};
|
||||
use structopt::StructOpt;
|
||||
|
||||
/// The `check-block` command used to validate blocks.
|
||||
@@ -48,21 +48,21 @@ pub struct CheckBlockCmd {
|
||||
|
||||
impl CheckBlockCmd {
|
||||
/// Run the check-block command
|
||||
pub async fn run<B, BC, BB>(
|
||||
pub async fn run<B, C, IQ>(
|
||||
&self,
|
||||
config: Configuration,
|
||||
builder: B,
|
||||
client: Arc<C>,
|
||||
import_queue: IQ,
|
||||
) -> error::Result<()>
|
||||
where
|
||||
B: FnOnce(Configuration) -> Result<BC, sc_service::error::Error>,
|
||||
BC: ServiceBuilderCommand<Block = BB> + Unpin,
|
||||
BB: BlockT + Debug,
|
||||
<NumberFor<BB> as FromStr>::Err: std::fmt::Debug,
|
||||
BB::Hash: FromStr,
|
||||
<BB::Hash as FromStr>::Err: std::fmt::Debug,
|
||||
B: BlockT + for<'de> serde::Deserialize<'de>,
|
||||
C: BlockBackend<B> + UsageProvider<B> + Send + Sync + 'static,
|
||||
IQ: sc_service::ImportQueue<B> + 'static,
|
||||
B::Hash: FromStr,
|
||||
<B::Hash as FromStr>::Err: Debug,
|
||||
<<B::Header as HeaderT>::Number as FromStr>::Err: Debug,
|
||||
{
|
||||
let start = std::time::Instant::now();
|
||||
builder(config)?.check_block(self.input.parse()?).await?;
|
||||
sc_service::chain_ops::check_block(client, import_queue, self.input.parse()?).await?;
|
||||
println!("Completed in {} ms.", start.elapsed().as_millis());
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user