|
@@ -24,7 +24,8 @@ use rand::{distributions::Alphanumeric, rngs::OsRng, Rng};
|
|
use structopt::StructOpt;
|
|
use structopt::StructOpt;
|
|
|
|
|
|
use joystream_node::chain_spec::{
|
|
use joystream_node::chain_spec::{
|
|
- self, chain_spec_properties, forum_config, initial_members, proposals_config, AccountId,
|
|
|
|
|
|
+ self, chain_spec_properties, content_config, forum_config, initial_members, proposals_config,
|
|
|
|
+ AccountId,
|
|
};
|
|
};
|
|
|
|
|
|
use sc_chain_spec::ChainType;
|
|
use sc_chain_spec::ChainType;
|
|
@@ -64,6 +65,9 @@ enum ChainSpecBuilder {
|
|
/// The path to an initial forum data
|
|
/// The path to an initial forum data
|
|
#[structopt(long, short)]
|
|
#[structopt(long, short)]
|
|
initial_forum_path: Option<PathBuf>,
|
|
initial_forum_path: Option<PathBuf>,
|
|
|
|
+ /// The path to an initial content directory data file
|
|
|
|
+ #[structopt(long, short)]
|
|
|
|
+ initial_content_path: Option<PathBuf>,
|
|
},
|
|
},
|
|
/// Create a new chain spec with the given number of authorities and endowed
|
|
/// Create a new chain spec with the given number of authorities and endowed
|
|
/// accounts. Random keys will be generated as required.
|
|
/// accounts. Random keys will be generated as required.
|
|
@@ -90,6 +94,9 @@ enum ChainSpecBuilder {
|
|
/// The path to an initial forum data
|
|
/// The path to an initial forum data
|
|
#[structopt(long, short)]
|
|
#[structopt(long, short)]
|
|
initial_forum_path: Option<PathBuf>,
|
|
initial_forum_path: Option<PathBuf>,
|
|
|
|
+ /// The path to an initial content directory data file
|
|
|
|
+ #[structopt(long, short)]
|
|
|
|
+ initial_content_path: Option<PathBuf>,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
|
|
@@ -106,7 +113,7 @@ impl ChainSpecBuilder {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /// Returns the path where the chain spec should be saved.
|
|
|
|
|
|
+ /// Returns the path to load initial members from
|
|
fn initial_members_path(&self) -> &Option<PathBuf> {
|
|
fn initial_members_path(&self) -> &Option<PathBuf> {
|
|
match self {
|
|
match self {
|
|
ChainSpecBuilder::New {
|
|
ChainSpecBuilder::New {
|
|
@@ -120,7 +127,7 @@ impl ChainSpecBuilder {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /// Returns the path where the chain spec should be saved.
|
|
|
|
|
|
+ /// Returns the path to load initial forum from
|
|
fn initial_forum_path(&self) -> &Option<PathBuf> {
|
|
fn initial_forum_path(&self) -> &Option<PathBuf> {
|
|
match self {
|
|
match self {
|
|
ChainSpecBuilder::New {
|
|
ChainSpecBuilder::New {
|
|
@@ -131,6 +138,20 @@ impl ChainSpecBuilder {
|
|
} => initial_forum_path,
|
|
} => initial_forum_path,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /// Returns the path to load initial platform content from
|
|
|
|
+ fn initial_content_path(&self) -> &Option<PathBuf> {
|
|
|
|
+ match self {
|
|
|
|
+ ChainSpecBuilder::New {
|
|
|
|
+ initial_content_path,
|
|
|
|
+ ..
|
|
|
|
+ } => initial_content_path,
|
|
|
|
+ ChainSpecBuilder::Generate {
|
|
|
|
+ initial_content_path,
|
|
|
|
+ ..
|
|
|
|
+ } => initial_content_path,
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
fn genesis_constructor(
|
|
fn genesis_constructor(
|
|
@@ -139,6 +160,7 @@ fn genesis_constructor(
|
|
sudo_account: &AccountId,
|
|
sudo_account: &AccountId,
|
|
initial_members_path: &Option<PathBuf>,
|
|
initial_members_path: &Option<PathBuf>,
|
|
initial_forum_path: &Option<PathBuf>,
|
|
initial_forum_path: &Option<PathBuf>,
|
|
|
|
+ initial_content_path: &Option<PathBuf>,
|
|
) -> chain_spec::GenesisConfig {
|
|
) -> chain_spec::GenesisConfig {
|
|
let authorities = authority_seeds
|
|
let authorities = authority_seeds
|
|
.iter()
|
|
.iter()
|
|
@@ -158,6 +180,12 @@ fn genesis_constructor(
|
|
forum_config::empty(sudo_account.clone())
|
|
forum_config::empty(sudo_account.clone())
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ let versioned_store_cfg = if let Some(path) = initial_content_path {
|
|
|
|
+ content_config::versioned_store_config_from_json(path.as_path())
|
|
|
|
+ } else {
|
|
|
|
+ content_config::empty_versioned_store_config()
|
|
|
|
+ };
|
|
|
|
+
|
|
chain_spec::testnet_genesis(
|
|
chain_spec::testnet_genesis(
|
|
authorities,
|
|
authorities,
|
|
sudo_account.clone(),
|
|
sudo_account.clone(),
|
|
@@ -165,6 +193,7 @@ fn genesis_constructor(
|
|
proposals_config::default(),
|
|
proposals_config::default(),
|
|
members,
|
|
members,
|
|
forum_cfg,
|
|
forum_cfg,
|
|
|
|
+ content_config::empty_versioned_store_config(),
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -174,6 +203,7 @@ fn generate_chain_spec(
|
|
sudo_account: String,
|
|
sudo_account: String,
|
|
initial_members_path: Option<PathBuf>,
|
|
initial_members_path: Option<PathBuf>,
|
|
initial_forum_path: Option<PathBuf>,
|
|
initial_forum_path: Option<PathBuf>,
|
|
|
|
+ initial_content_path: Option<PathBuf>,
|
|
) -> Result<String, String> {
|
|
) -> Result<String, String> {
|
|
let parse_account = |address: &String| {
|
|
let parse_account = |address: &String| {
|
|
AccountId::from_string(address)
|
|
AccountId::from_string(address)
|
|
@@ -205,6 +235,7 @@ fn generate_chain_spec(
|
|
&sudo_account,
|
|
&sudo_account,
|
|
&initial_members_path,
|
|
&initial_members_path,
|
|
&initial_forum_path,
|
|
&initial_forum_path,
|
|
|
|
+ &initial_content_path,
|
|
)
|
|
)
|
|
},
|
|
},
|
|
vec![],
|
|
vec![],
|
|
@@ -278,6 +309,7 @@ fn main() -> Result<(), String> {
|
|
let chain_spec_path = builder.chain_spec_path().to_path_buf();
|
|
let chain_spec_path = builder.chain_spec_path().to_path_buf();
|
|
let initial_members_path = builder.initial_members_path().clone();
|
|
let initial_members_path = builder.initial_members_path().clone();
|
|
let initial_forum_path = builder.initial_forum_path().clone();
|
|
let initial_forum_path = builder.initial_forum_path().clone();
|
|
|
|
+ let initial_content_path = builder.initial_content_path().clone();
|
|
|
|
|
|
let (authority_seeds, endowed_accounts, sudo_account) = match builder {
|
|
let (authority_seeds, endowed_accounts, sudo_account) = match builder {
|
|
ChainSpecBuilder::Generate {
|
|
ChainSpecBuilder::Generate {
|
|
@@ -326,6 +358,7 @@ fn main() -> Result<(), String> {
|
|
sudo_account,
|
|
sudo_account,
|
|
initial_members_path,
|
|
initial_members_path,
|
|
initial_forum_path,
|
|
initial_forum_path,
|
|
|
|
+ initial_content_path,
|
|
)?;
|
|
)?;
|
|
|
|
|
|
fs::write(chain_spec_path, json).map_err(|err| err.to_string())
|
|
fs::write(chain_spec_path, json).map_err(|err| err.to_string())
|