do not wait idiotic 30 seconds when running regtests
This commit is contained in:
parent
f4e5130faf
commit
e1a2915a90
|
@ -2,7 +2,7 @@ use std::net::SocketAddr;
|
||||||
use sync::create_sync_connection_factory;
|
use sync::create_sync_connection_factory;
|
||||||
use message::Services;
|
use message::Services;
|
||||||
use util::{open_db, init_db, node_table_path};
|
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> {
|
pub fn start(cfg: config::Config) -> Result<(), String> {
|
||||||
let mut el = p2p::event_loop();
|
let mut el = p2p::event_loop();
|
||||||
|
@ -22,7 +22,7 @@ pub fn start(cfg: config::Config) -> Result<(), String> {
|
||||||
magic: cfg.magic,
|
magic: cfg.magic,
|
||||||
local_address: SocketAddr::new("127.0.0.1".parse().unwrap(), cfg.port),
|
local_address: SocketAddr::new("127.0.0.1".parse().unwrap(), cfg.port),
|
||||||
services: Services::default().with_network(true),
|
services: Services::default().with_network(true),
|
||||||
user_agent: USER_AGENT.into(),
|
user_agent: cfg.user_agent,
|
||||||
start_height: 0,
|
start_height: 0,
|
||||||
relay: false,
|
relay: false,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use std::net;
|
use std::net;
|
||||||
use clap;
|
use clap;
|
||||||
use message::Magic;
|
use message::Magic;
|
||||||
|
use {USER_AGENT, REGTEST_USER_AGENT};
|
||||||
|
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub magic: Magic,
|
pub magic: Magic,
|
||||||
|
@ -13,6 +14,7 @@ pub struct Config {
|
||||||
pub p2p_threads: usize,
|
pub p2p_threads: usize,
|
||||||
pub db_cache: usize,
|
pub db_cache: usize,
|
||||||
pub data_dir: Option<String>,
|
pub data_dir: Option<String>,
|
||||||
|
pub user_agent: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const DEFAULT_DB_CACHE: usize = 512;
|
pub const DEFAULT_DB_CACHE: usize = 512;
|
||||||
|
@ -36,6 +38,12 @@ pub fn parse(matches: &clap::ArgMatches) -> Result<Config, String> {
|
||||||
Magic::Regtest => 1,
|
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") {
|
let port = match matches.value_of("port") {
|
||||||
Some(port) => try!(port.parse().map_err(|_| "Invalid port".to_owned())),
|
Some(port) => try!(port.parse().map_err(|_| "Invalid port".to_owned())),
|
||||||
None => magic.port(),
|
None => magic.port(),
|
||||||
|
@ -77,6 +85,7 @@ pub fn parse(matches: &clap::ArgMatches) -> Result<Config, String> {
|
||||||
p2p_threads: p2p_threads,
|
p2p_threads: p2p_threads,
|
||||||
db_cache: db_cache,
|
db_cache: db_cache,
|
||||||
data_dir: data_dir,
|
data_dir: data_dir,
|
||||||
|
user_agent: user_agent.to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(config)
|
Ok(config)
|
||||||
|
|
|
@ -26,6 +26,7 @@ pub const APP_INFO: AppInfo = AppInfo { name: "pbtc", author: "Parity" };
|
||||||
pub const PROTOCOL_VERSION: u32 = 70_014;
|
pub const PROTOCOL_VERSION: u32 = 70_014;
|
||||||
pub const PROTOCOL_MINIMUM: u32 = 70_001;
|
pub const PROTOCOL_MINIMUM: u32 = 70_001;
|
||||||
pub const USER_AGENT: &'static str = "pbtc";
|
pub const USER_AGENT: &'static str = "pbtc";
|
||||||
|
pub const REGTEST_USER_AGENT: &'static str = "/Satoshi:0.12.1/";
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
env_logger::init().unwrap();
|
env_logger::init().unwrap();
|
||||||
|
|
Loading…
Reference in New Issue