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;
|
2016-10-19 05:17:18 -07:00
|
|
|
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;
|
2016-10-27 07:26:12 -07:00
|
|
|
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;
|
2016-11-25 09:38:21 -08:00
|
|
|
extern crate network;
|
2016-09-30 05:59:16 -07:00
|
|
|
extern crate p2p;
|
2016-10-24 07:38:33 -07:00
|
|
|
extern crate sync;
|
2016-10-30 19:12:44 -07:00
|
|
|
extern crate import;
|
2016-12-07 05:14:52 -08:00
|
|
|
extern crate rpc as ethcore_rpc;
|
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;
|
2016-12-07 05:14:52 -08:00
|
|
|
mod rpc;
|
|
|
|
mod rpc_apis;
|
2016-11-03 09:19:35 -07:00
|
|
|
|
|
|
|
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" };
|
2016-11-16 16:02:34 -08:00
|
|
|
pub const PROTOCOL_VERSION: u32 = 70_014;
|
|
|
|
pub const PROTOCOL_MINIMUM: u32 = 70_001;
|
|
|
|
pub const USER_AGENT: &'static str = "pbtc";
|
2016-11-25 03:37:27 -08:00
|
|
|
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-10-03 06:44:35 -07:00
|
|
|
|
2016-09-30 05:44:50 -07:00
|
|
|
fn main() {
|
2016-11-08 02:51:34 -08:00
|
|
|
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
|
|
|
}
|