Skip to content

Commit

Permalink
feat: refactor chain spec config (#224)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The chainspec path in node's configuration
json file changed from "ckb.chain" to "chain.spec".
  • Loading branch information
Jan Xie authored and doitian committed Jan 25, 2019
1 parent f7304e7 commit 4f85163
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions nodes_template/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
},

"data_dir": "default",
"ckb": {
"chain": "spec/dev.json"
"chain": {
"spec": "spec/dev.json"
},
"logger": {
"file": "ckb.log",
Expand Down
16 changes: 8 additions & 8 deletions src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ pub struct Setup {
}

#[derive(Clone, Debug, Deserialize)]
pub struct CKB {
pub chain: PathBuf,
pub struct ChainConfig {
pub spec: PathBuf,
}

#[derive(Clone, Debug, Deserialize)]
pub struct Configs {
pub data_dir: PathBuf,
pub ckb: CKB,
pub chain: ChainConfig,
pub logger: LogConfig,
pub network: NetworkConfig,
pub rpc: RpcConfig,
Expand Down Expand Up @@ -74,7 +74,7 @@ impl Setup {
Some(dirs.join("network").to_string_lossy().to_string());
}

let chain_spec = ChainSpec::read_from_file(&configs.ckb.chain)?;
let chain_spec = ChainSpec::read_from_file(&configs.chain.spec)?;

Ok(Setup {
configs,
Expand All @@ -100,8 +100,8 @@ impl Configs {
if self.data_dir.is_relative() {
self.data_dir = base.join(&self.data_dir);
}
if self.ckb.chain.is_relative() {
self.ckb.chain = base.join(&self.ckb.chain);
if self.chain.spec.is_relative() {
self.chain.spec = base.join(&self.chain.spec);
}
}
}
Expand Down Expand Up @@ -203,8 +203,8 @@ pub mod test {
let test_conifg = format!(
r#"
{{
"ckb": {{
"chain": "{}"
"chain": {{
"spec": "{}"
}}
}}"#,
chain_spec_path.to_str().unwrap()
Expand Down

0 comments on commit 4f85163

Please sign in to comment.