mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 15:41:02 +00:00
Add output positional arg to undying-collator cli (#2375)
Follow up from https://github.com/paritytech/polkadot-sdk/pull/2370 to add `output` positional argument to undying-collator. cc @JoshOrndorff --------- Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use sc_cli::SubstrateCli;
|
use sc_cli::SubstrateCli;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
/// Sub-commands supported by the collator.
|
/// Sub-commands supported by the collator.
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
@@ -34,6 +35,10 @@ pub enum Subcommand {
|
|||||||
/// Command for exporting the genesis state of the parachain
|
/// Command for exporting the genesis state of the parachain
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct ExportGenesisStateCommand {
|
pub struct ExportGenesisStateCommand {
|
||||||
|
/// Output file name or stdout if unspecified.
|
||||||
|
#[arg()]
|
||||||
|
pub output: Option<PathBuf>,
|
||||||
|
|
||||||
/// Id of the parachain this collator collates for.
|
/// Id of the parachain this collator collates for.
|
||||||
#[arg(long, default_value_t = 100)]
|
#[arg(long, default_value_t = 100)]
|
||||||
pub parachain_id: u32,
|
pub parachain_id: u32,
|
||||||
@@ -50,7 +55,11 @@ pub struct ExportGenesisStateCommand {
|
|||||||
|
|
||||||
/// Command for exporting the genesis wasm file.
|
/// Command for exporting the genesis wasm file.
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct ExportGenesisWasmCommand {}
|
pub struct ExportGenesisWasmCommand {
|
||||||
|
/// Output file name or stdout if unspecified.
|
||||||
|
#[arg()]
|
||||||
|
pub output: Option<PathBuf>,
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProt
|
|||||||
use polkadot_primitives::Id as ParaId;
|
use polkadot_primitives::Id as ParaId;
|
||||||
use sc_cli::{Error as SubstrateCliError, SubstrateCli};
|
use sc_cli::{Error as SubstrateCliError, SubstrateCli};
|
||||||
use sp_core::hexdisplay::HexDisplay;
|
use sp_core::hexdisplay::HexDisplay;
|
||||||
|
use std::{
|
||||||
|
fs,
|
||||||
|
io::{self, Write},
|
||||||
|
};
|
||||||
use test_parachain_undying_collator::Collator;
|
use test_parachain_undying_collator::Collator;
|
||||||
|
|
||||||
mod cli;
|
mod cli;
|
||||||
@@ -35,14 +39,30 @@ fn main() -> Result<()> {
|
|||||||
// `pov_size` and `pvf_complexity` need to match the ones that we start the collator
|
// `pov_size` and `pvf_complexity` need to match the ones that we start the collator
|
||||||
// with.
|
// with.
|
||||||
let collator = Collator::new(params.pov_size, params.pvf_complexity);
|
let collator = Collator::new(params.pov_size, params.pvf_complexity);
|
||||||
println!("0x{:?}", HexDisplay::from(&collator.genesis_head()));
|
|
||||||
|
let output_buf =
|
||||||
|
format!("0x{:?}", HexDisplay::from(&collator.genesis_head())).into_bytes();
|
||||||
|
|
||||||
|
if let Some(output) = params.output {
|
||||||
|
std::fs::write(output, output_buf)?;
|
||||||
|
} else {
|
||||||
|
std::io::stdout().write_all(&output_buf)?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok::<_, Error>(())
|
Ok::<_, Error>(())
|
||||||
},
|
},
|
||||||
Some(cli::Subcommand::ExportGenesisWasm(_params)) => {
|
Some(cli::Subcommand::ExportGenesisWasm(params)) => {
|
||||||
// We pass some dummy values for `pov_size` and `pvf_complexity` as these don't
|
// We pass some dummy values for `pov_size` and `pvf_complexity` as these don't
|
||||||
// matter for `wasm` export.
|
// matter for `wasm` export.
|
||||||
println!("0x{:?}", HexDisplay::from(&Collator::default().validation_code()));
|
let output_buf =
|
||||||
|
format!("0x{:?}", HexDisplay::from(&Collator::default().validation_code()))
|
||||||
|
.into_bytes();
|
||||||
|
|
||||||
|
if let Some(output) = params.output {
|
||||||
|
fs::write(output, output_buf)?;
|
||||||
|
} else {
|
||||||
|
io::stdout().write_all(&output_buf)?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user