mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-29 07:17:17 +00:00
Merge pull request #270 from thojest/lighthouse-252
ChainSpec selectable via CLI flag
This commit is contained in:
commit
f4c4be7a37
@ -1,11 +1,13 @@
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use types::ChainSpec;
|
||||
|
||||
/// Stores the core configuration for this validator instance.
|
||||
#[derive(Clone)]
|
||||
pub struct ClientConfig {
|
||||
pub data_dir: PathBuf,
|
||||
pub server: String,
|
||||
pub spec: ChainSpec,
|
||||
}
|
||||
|
||||
const DEFAULT_LIGHTHOUSE_DIR: &str = ".lighthouse-validators";
|
||||
@ -20,6 +22,11 @@ impl ClientConfig {
|
||||
fs::create_dir_all(&data_dir)
|
||||
.unwrap_or_else(|_| panic!("Unable to create {:?}", &data_dir));
|
||||
let server = "localhost:50051".to_string();
|
||||
Self { data_dir, server }
|
||||
let spec = ChainSpec::foundation();
|
||||
Self {
|
||||
data_dir,
|
||||
server,
|
||||
spec,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,16 @@ fn main() {
|
||||
.help("Address to connect to BeaconNode.")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("spec")
|
||||
.long("spec")
|
||||
.value_name("spec")
|
||||
.short("s")
|
||||
.help("Configuration of Beacon Chain")
|
||||
.takes_value(true)
|
||||
.possible_values(&["foundation", "few_validators"])
|
||||
.default_value("foundation"),
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
let mut config = ClientConfig::default();
|
||||
@ -62,6 +72,17 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Permit loading a custom spec from file.
|
||||
// Custom spec
|
||||
if let Some(spec_str) = matches.value_of("spec") {
|
||||
match spec_str {
|
||||
"foundation" => config.spec = ChainSpec::foundation(),
|
||||
"few_validators" => config.spec = ChainSpec::few_validators(),
|
||||
// Should be impossible due to clap's `possible_values(..)` function.
|
||||
_ => unreachable!(),
|
||||
};
|
||||
}
|
||||
|
||||
// Log configuration
|
||||
info!(log, "";
|
||||
"data_dir" => &config.data_dir.to_str(),
|
||||
@ -81,11 +102,8 @@ fn main() {
|
||||
Arc::new(ValidatorServiceClient::new(ch))
|
||||
};
|
||||
|
||||
// Ethereum
|
||||
//
|
||||
// TODO: Permit loading a custom spec from file.
|
||||
// https://github.com/sigp/lighthouse/issues/160
|
||||
let spec = Arc::new(ChainSpec::foundation());
|
||||
// Spec
|
||||
let spec = Arc::new(config.spec.clone());
|
||||
|
||||
// Clock for determining the present slot.
|
||||
// TODO: this shouldn't be a static time, instead it should be pulled from the beacon node.
|
||||
|
Loading…
Reference in New Issue
Block a user