lighthouse-pulse/lighthouse/main.rs

82 lines
2.0 KiB
Rust
Raw Normal View History

2018-09-26 04:06:16 +00:00
#![feature(test)]
2018-07-28 00:02:45 +00:00
#[macro_use]
extern crate slog;
extern crate slog_term;
extern crate slog_async;
2018-09-23 10:19:30 +00:00
extern crate ssz;
2018-07-28 00:02:45 +00:00
extern crate clap;
2018-08-07 00:08:39 +00:00
extern crate network_libp2p;
2018-08-16 04:17:28 +00:00
extern crate futures;
2018-07-28 00:02:45 +00:00
2018-09-19 04:00:35 +00:00
#[macro_use]
#[allow(dead_code)]
mod utils;
#[allow(dead_code)]
mod bls;
#[allow(dead_code)]
mod db;
mod client;
#[allow(dead_code)]
mod state;
#[allow(dead_code)]
mod sync;
mod config;
2018-07-28 00:02:45 +00:00
use std::path::PathBuf;
2018-09-26 01:36:07 +00:00
use slog::Drain;
use clap::{ Arg, App };
2018-08-06 23:13:24 +00:00
use config::LighthouseConfig;
2018-08-16 04:17:28 +00:00
use client::Client;
2018-07-28 00:02:45 +00:00
fn main() {
let decorator = slog_term::TermDecorator::new().build();
let drain = slog_term::CompactFormat::new(decorator).build().fuse();
let drain = slog_async::Async::new(drain).build().fuse();
let log = slog::Logger::root(drain, o!());
let matches = App::new("Lighthouse")
.version("0.0.1")
.author("Sigma Prime <paul@sigmaprime.io>")
2018-07-28 00:02:45 +00:00
.about("Eth 2.0 Client")
.arg(Arg::with_name("datadir")
.long("datadir")
.value_name("DIR")
.help("Data directory for keys and databases.")
.takes_value(true))
.arg(Arg::with_name("port")
.long("port")
.value_name("PORT")
.help("Network listen port for p2p connections.")
.takes_value(true))
2018-07-28 00:02:45 +00:00
.get_matches();
2018-08-06 23:13:24 +00:00
let mut config = LighthouseConfig::default();
// Custom datadir
if let Some(dir) = matches.value_of("datadir") {
config.data_dir = PathBuf::from(dir.to_string());
}
2018-08-06 23:13:24 +00:00
// Custom p2p listen port
2018-08-07 00:08:39 +00:00
if let Some(port_str) = matches.value_of("port") {
if let Ok(port) = port_str.parse::<u16>() {
config.p2p_listen_port = port;
} else {
error!(log, "Invalid port"; "port" => port_str);
return;
}
}
2018-08-07 00:08:39 +00:00
// Log configuration
info!(log, "";
2018-08-07 00:08:39 +00:00
"data_dir" => &config.data_dir.to_str(),
"port" => &config.p2p_listen_port);
2018-08-16 04:17:28 +00:00
2018-09-21 22:17:31 +00:00
let client = Client::new(&config, &log);
2018-08-23 05:11:02 +00:00
client.sync_thread.join().unwrap();
2018-07-28 00:02:45 +00:00
info!(log, "Exiting.");
}