soil_cli/commands/
check_block_cmd.rs1use crate::{
8 error,
9 params::{BlockNumberOrHash, ImportParams, SharedParams},
10 CliConfiguration,
11};
12use clap::Parser;
13use soil_client::client_api::{BlockBackend, HeaderBackend};
14use std::{fmt::Debug, str::FromStr, sync::Arc};
15use subsoil::runtime::traits::{Block as BlockT, Header as HeaderT};
16
17#[derive(Debug, Clone, Parser)]
19pub struct CheckBlockCmd {
20 #[arg(value_name = "HASH or NUMBER")]
22 pub input: BlockNumberOrHash,
23
24 #[arg(long, value_name = "COUNT")]
27 pub default_heap_pages: Option<u32>,
28
29 #[allow(missing_docs)]
30 #[clap(flatten)]
31 pub shared_params: SharedParams,
32
33 #[allow(missing_docs)]
34 #[clap(flatten)]
35 pub import_params: ImportParams,
36}
37
38impl CheckBlockCmd {
39 pub async fn run<B, C, IQ>(&self, client: Arc<C>, import_queue: IQ) -> error::Result<()>
41 where
42 B: BlockT + for<'de> serde::Deserialize<'de>,
43 C: BlockBackend<B> + HeaderBackend<B> + Send + Sync + 'static,
44 IQ: soil_service::ImportQueue<B> + 'static,
45 <B::Hash as FromStr>::Err: Debug,
46 <<B::Header as HeaderT>::Number as FromStr>::Err: Debug,
47 {
48 let start = std::time::Instant::now();
49 soil_service::chain_ops::check_block(client, import_queue, self.input.parse()?).await?;
50 println!("Completed in {} ms.", start.elapsed().as_millis());
51
52 Ok(())
53 }
54}
55
56impl CliConfiguration for CheckBlockCmd {
57 fn shared_params(&self) -> &SharedParams {
58 &self.shared_params
59 }
60
61 fn import_params(&self) -> Option<&ImportParams> {
62 Some(&self.import_params)
63 }
64}