diff --git a/pbtc/commands/start.rs b/pbtc/commands/start.rs index 0059970b..1cd872b8 100644 --- a/pbtc/commands/start.rs +++ b/pbtc/commands/start.rs @@ -2,7 +2,7 @@ use std::net::SocketAddr; use sync::create_sync_connection_factory; use message::Services; use util::{open_db, init_db, node_table_path}; -use {config, p2p, PROTOCOL_VERSION, PROTOCOL_MINIMUM, USER_AGENT}; +use {config, p2p, PROTOCOL_VERSION, PROTOCOL_MINIMUM}; pub fn start(cfg: config::Config) -> Result<(), String> { let mut el = p2p::event_loop(); @@ -22,7 +22,7 @@ pub fn start(cfg: config::Config) -> Result<(), String> { magic: cfg.magic, local_address: SocketAddr::new("127.0.0.1".parse().unwrap(), cfg.port), services: Services::default().with_network(true), - user_agent: USER_AGENT.into(), + user_agent: cfg.user_agent, start_height: 0, relay: false, }, diff --git a/pbtc/config.rs b/pbtc/config.rs index e967531d..95e4b47c 100644 --- a/pbtc/config.rs +++ b/pbtc/config.rs @@ -1,6 +1,7 @@ use std::net; use clap; use message::Magic; +use {USER_AGENT, REGTEST_USER_AGENT}; pub struct Config { pub magic: Magic, @@ -13,6 +14,7 @@ pub struct Config { pub p2p_threads: usize, pub db_cache: usize, pub data_dir: Option, + pub user_agent: String, } pub const DEFAULT_DB_CACHE: usize = 512; @@ -36,6 +38,12 @@ pub fn parse(matches: &clap::ArgMatches) -> Result { Magic::Regtest => 1, }; + // to skip idiotic 30 seconds delay in test-scripts + let user_agent = match magic { + Magic::Testnet | Magic::Mainnet => USER_AGENT, + Magic::Regtest => REGTEST_USER_AGENT, + }; + let port = match matches.value_of("port") { Some(port) => try!(port.parse().map_err(|_| "Invalid port".to_owned())), None => magic.port(), @@ -77,6 +85,7 @@ pub fn parse(matches: &clap::ArgMatches) -> Result { p2p_threads: p2p_threads, db_cache: db_cache, data_dir: data_dir, + user_agent: user_agent.to_string(), }; Ok(config) diff --git a/pbtc/main.rs b/pbtc/main.rs index 6ac29f97..e524839e 100644 --- a/pbtc/main.rs +++ b/pbtc/main.rs @@ -26,6 +26,7 @@ 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/"; fn main() { env_logger::init().unwrap();