parity-zcash/pbtc/main.rs

52 lines
1.0 KiB
Rust
Raw Normal View History

2016-09-30 05:44:50 -07:00
//! Parity bitcoin client.
#[macro_use]
extern crate clap;
extern crate bitcrypto as crypto;
extern crate chain;
extern crate keys;
extern crate primitives;
extern crate script;
2016-09-30 05:59:16 -07:00
extern crate net;
extern crate p2p;
use net::common::Magic;
2016-09-30 05:44:50 -07:00
fn main() {
let yaml = load_yaml!("cli.yml");
let matches = clap::App::from_yaml(yaml).get_matches();
2016-09-30 07:25:28 -07:00
let _cfg = parse(&matches);
}
struct Config<'a> {
magic: Magic,
port: u16,
connect: Option<&'a str>,
seednode: Option<&'a str>,
}
2016-09-30 05:44:50 -07:00
2016-09-30 07:25:28 -07:00
fn parse<'a>(matches: &'a clap::ArgMatches<'a>) -> Result<Config<'a>, String> {
let magic = match matches.is_present("testnet") {
2016-09-30 05:59:16 -07:00
true => Magic::Testnet,
false => Magic::Mainnet,
};
2016-09-30 07:25:28 -07:00
let port = match matches.value_of("port") {
Some(port) => try!(port.parse().map_err(|_| "Invalid port".to_owned())),
None => match magic {
Magic::Mainnet => 8333,
Magic::Testnet => 18333,
},
};
let config = Config {
magic: magic,
port: port,
connect: matches.value_of("connect"),
seednode: matches.value_of("seednode"),
};
2016-09-30 05:59:16 -07:00
2016-09-30 07:25:28 -07:00
Ok(config)
2016-09-30 05:44:50 -07:00
}