mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 23:47:56 +00:00
chain spec builder: add generate mode for authority keys (#3811)
* core: use trait object for genesis constructor * chain-spec-builder: use structopt * chain-spec-builder: add new command to generate authority keys * chain-spec-builder: use ? in main * chain-spec-builder: fix stored and printed suri from seed * chain-spec-builder: add comment about created keystore folders * chain-spec-builder: simplify file write
This commit is contained in:
@@ -20,6 +20,7 @@ use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::fs::File;
|
||||
use std::path::PathBuf;
|
||||
use std::rc::Rc;
|
||||
use serde::{Serialize, Deserialize};
|
||||
use primitives::storage::{StorageKey, StorageData};
|
||||
use sr_primitives::{BuildStorage, StorageOverlay, ChildrenStorageOverlay};
|
||||
@@ -31,7 +32,7 @@ use tel::TelemetryEndpoints;
|
||||
enum GenesisSource<G> {
|
||||
File(PathBuf),
|
||||
Binary(Cow<'static, [u8]>),
|
||||
Factory(fn() -> G),
|
||||
Factory(Rc<dyn Fn() -> G>),
|
||||
}
|
||||
|
||||
impl<G> Clone for GenesisSource<G> {
|
||||
@@ -39,7 +40,7 @@ impl<G> Clone for GenesisSource<G> {
|
||||
match *self {
|
||||
GenesisSource::File(ref path) => GenesisSource::File(path.clone()),
|
||||
GenesisSource::Binary(ref d) => GenesisSource::Binary(d.clone()),
|
||||
GenesisSource::Factory(f) => GenesisSource::Factory(f),
|
||||
GenesisSource::Factory(ref f) => GenesisSource::Factory(f.clone()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -187,10 +188,10 @@ impl<G, E> ChainSpec<G, E> {
|
||||
}
|
||||
|
||||
/// Create hardcoded spec.
|
||||
pub fn from_genesis(
|
||||
pub fn from_genesis<F: Fn() -> G + 'static>(
|
||||
name: &str,
|
||||
id: &str,
|
||||
constructor: fn() -> G,
|
||||
constructor: F,
|
||||
boot_nodes: Vec<String>,
|
||||
telemetry_endpoints: Option<TelemetryEndpoints>,
|
||||
protocol_id: Option<&str>,
|
||||
@@ -211,7 +212,7 @@ impl<G, E> ChainSpec<G, E> {
|
||||
|
||||
ChainSpec {
|
||||
spec,
|
||||
genesis: GenesisSource::Factory(constructor),
|
||||
genesis: GenesisSource::Factory(Rc::new(constructor)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user