parity-zcash/pbtc/main.rs

61 lines
1.3 KiB
Rust
Raw Normal View History

2016-09-30 05:44:50 -07:00
//! Parity bitcoin client.
#[macro_use]
extern crate clap;
2016-11-03 09:19:35 -07:00
#[macro_use]
extern crate log;
extern crate env_logger;
2016-11-03 09:19:35 -07:00
extern crate app_dirs;
2016-09-30 05:44:50 -07:00
2016-10-30 19:12:44 -07:00
extern crate db;
extern crate chain;
2016-09-30 05:44:50 -07:00
extern crate keys;
2016-12-01 01:40:56 -08:00
extern crate logs;
2016-09-30 05:44:50 -07:00
extern crate script;
2016-10-03 07:29:07 -07:00
extern crate message;
extern crate network;
2016-09-30 05:59:16 -07:00
extern crate p2p;
extern crate sync;
2016-10-30 19:12:44 -07:00
extern crate import;
2016-09-30 05:59:16 -07:00
2016-11-03 09:19:35 -07:00
mod commands;
2016-10-02 18:01:46 -07:00
mod config;
2016-11-30 05:37:17 -08:00
mod seednodes;
2016-11-03 09:19:35 -07:00
mod util;
use app_dirs::AppInfo;
2016-09-30 05:44:50 -07:00
2016-11-03 09:19:35 -07:00
pub const APP_INFO: AppInfo = AppInfo { name: "pbtc", author: "Parity" };
pub const PROTOCOL_VERSION: u32 = 70_014;
pub const PROTOCOL_MINIMUM: u32 = 70_001;
pub const USER_AGENT: &'static str = "pbtc";
pub const REGTEST_USER_AGENT: &'static str = "/Satoshi:0.12.1/";
2016-12-01 01:40:56 -08:00
pub const LOG_INFO: &'static str = "sync=info";
2016-09-30 05:44:50 -07:00
fn main() {
if let Err(err) = run() {
println!("{}", err);
2016-10-02 18:01:46 -07:00
}
}
fn run() -> Result<(), String> {
2016-09-30 05:44:50 -07:00
let yaml = load_yaml!("cli.yml");
let matches = clap::App::from_yaml(yaml).get_matches();
2016-11-03 09:19:35 -07:00
let cfg = try!(config::parse(&matches));
2016-09-30 07:25:28 -07:00
2016-12-01 01:40:56 -08:00
if cfg.print_to_console {
if cfg!(windows) {
logs::init(LOG_INFO, logs::DateLogFormatter);
} else {
logs::init(LOG_INFO, logs::DateAndColorLogFormatter);
}
} else {
2016-12-01 01:46:03 -08:00
env_logger::init().expect("Logger can be initialized only once");
2016-12-01 01:40:56 -08:00
}
2016-11-03 03:53:39 -07:00
match matches.subcommand() {
2016-11-03 09:19:35 -07:00
("import", Some(import_matches)) => commands::import(cfg, import_matches),
_ => commands::start(cfg),
2016-10-30 19:12:44 -07:00
}
2016-11-03 03:53:39 -07:00
}