如何在 substrate 框架中使用 --staging 标志?

how to use --staging flag in substrate framework?

如果我尝试运行以下命令:

./target/release/node-template build-spec --chain staging > stagingSpec.json

遇到以下错误:

Error: Input("Error opening spec file: No such file or directory (os error 2)")

有没有关于如何使用该暂存标志的指南??

这里是 the rustdocs for the command, and it's implementation in the node template - this looks for specific from your chain specification 文件,根据您传递的内容进行配置。在撰写本文时的模板中,模板只有 dev 和“其他所有”模式:

    fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
        Ok(match id {
            "dev" => Box::new(chain_spec::development_config()?),
            "" | "local" => Box::new(chain_spec::local_testnet_config()?),
            path =>
                Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
        })
    }

因此您需要在 /node/src/chainspec.rs 中指定另一个并配置 /node/src/commnad.rs 以在调用时使用正确的。