|
@ -5,6 +5,7 @@ use std::net::SocketAddr; |
|
|
#[derive(Debug)] |
|
|
#[derive(Debug)] |
|
|
pub struct Config { |
|
|
pub struct Config { |
|
|
pub verbosity: usize, |
|
|
pub verbosity: usize, |
|
|
|
|
|
pub timestamp: bool, |
|
|
pub network_type: Network, // bitcoind JSONRPC endpoint
|
|
|
pub network_type: Network, // bitcoind JSONRPC endpoint
|
|
|
pub db_path: String, // RocksDB directory path
|
|
|
pub db_path: String, // RocksDB directory path
|
|
|
pub rpc_addr: SocketAddr, // for serving Electrum clients
|
|
|
pub rpc_addr: SocketAddr, // for serving Electrum clients
|
|
@ -21,6 +22,11 @@ impl Config { |
|
|
.multiple(true) |
|
|
.multiple(true) |
|
|
.help("Increase logging verbosity"), |
|
|
.help("Increase logging verbosity"), |
|
|
) |
|
|
) |
|
|
|
|
|
.arg( |
|
|
|
|
|
Arg::with_name("timestamp") |
|
|
|
|
|
.long("timestamp") |
|
|
|
|
|
.help("Prepend log lines with a timestamp"), |
|
|
|
|
|
) |
|
|
.arg( |
|
|
.arg( |
|
|
Arg::with_name("db_dir") |
|
|
Arg::with_name("db_dir") |
|
|
.short("d") |
|
|
.short("d") |
|
@ -41,6 +47,7 @@ impl Config { |
|
|
let db_dir = m.value_of("db_dir").unwrap_or("./db"); |
|
|
let db_dir = m.value_of("db_dir").unwrap_or("./db"); |
|
|
Config { |
|
|
Config { |
|
|
verbosity: m.occurrences_of("verbosity") as usize, |
|
|
verbosity: m.occurrences_of("verbosity") as usize, |
|
|
|
|
|
timestamp: m.is_present("timestamp"), |
|
|
network_type, |
|
|
network_type, |
|
|
db_path: match network_type { |
|
|
db_path: match network_type { |
|
|
Network::Mainnet => format!("{}/mainnet", db_dir), |
|
|
Network::Mainnet => format!("{}/mainnet", db_dir), |
|
|