2019-02-14 01:09:18 +00:00
|
|
|
use std::fs;
|
|
|
|
use std::path::PathBuf;
|
2019-03-01 17:19:08 +00:00
|
|
|
use types::ChainSpec;
|
2019-02-14 01:09:18 +00:00
|
|
|
|
|
|
|
/// Stores the core configuration for this validator instance.
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct ClientConfig {
|
|
|
|
pub data_dir: PathBuf,
|
|
|
|
pub server: String,
|
2019-03-01 17:19:08 +00:00
|
|
|
pub spec: ChainSpec,
|
2019-02-14 01:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const DEFAULT_LIGHTHOUSE_DIR: &str = ".lighthouse-validators";
|
|
|
|
|
|
|
|
impl ClientConfig {
|
|
|
|
/// Build a new configuration from defaults.
|
|
|
|
pub fn default() -> Self {
|
|
|
|
let data_dir = {
|
|
|
|
let home = dirs::home_dir().expect("Unable to determine home dir.");
|
|
|
|
home.join(DEFAULT_LIGHTHOUSE_DIR)
|
|
|
|
};
|
|
|
|
fs::create_dir_all(&data_dir)
|
|
|
|
.unwrap_or_else(|_| panic!("Unable to create {:?}", &data_dir));
|
|
|
|
let server = "localhost:50051".to_string();
|
2019-03-01 17:19:08 +00:00
|
|
|
let spec = ChainSpec::foundation();
|
|
|
|
Self {
|
|
|
|
data_dir,
|
|
|
|
server,
|
|
|
|
spec,
|
|
|
|
}
|
2019-02-14 01:09:18 +00:00
|
|
|
}
|
|
|
|
}
|