mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-19 04:42:34 +00:00
Add persistent network identification
This commit is contained in:
@@ -9,9 +9,10 @@ mod signer;
|
||||
use crate::config::Config as ValidatorClientConfig;
|
||||
use crate::service::Service as ValidatorService;
|
||||
use clap::{App, Arg};
|
||||
use eth2_config::{get_data_dir, read_from_file, write_to_file, Eth2Config};
|
||||
use eth2_config::{read_from_file, write_to_file, Eth2Config};
|
||||
use protos::services_grpc::ValidatorServiceClient;
|
||||
use slog::{crit, error, info, o, Drain};
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use types::{Keypair, MainnetEthSpec, MinimalEthSpec};
|
||||
|
||||
@@ -66,13 +67,22 @@ fn main() {
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
let data_dir = match get_data_dir(&matches, PathBuf::from(DEFAULT_DATA_DIR)) {
|
||||
Ok(dir) => dir,
|
||||
let mut default_dir = dirs::home_dir().unwrap_or_else(|| PathBuf::from("."));
|
||||
default_dir.push(DEFAULT_DATA_DIR);
|
||||
|
||||
let data_dir = &matches
|
||||
.value_of("datadir")
|
||||
.and_then(|v| Some(PathBuf::from(v)))
|
||||
.unwrap_or_else(|| PathBuf::from(default_dir));
|
||||
|
||||
// create the directory if needed
|
||||
match fs::create_dir_all(&data_dir) {
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
crit!(log, "Failed to initialize data dir"; "error" => format!("{:?}", e));
|
||||
crit!(log, "Failed to initialize data dir"; "error" => format!("{}", e));
|
||||
return;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let client_config_path = data_dir.join(CLIENT_CONFIG_FILENAME);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user