Merge branch 'master' into respect_minimal_protocol_version
This commit is contained in:
commit
035583fac1
|
@ -7,7 +7,7 @@ pub struct GetAddr;
|
|||
|
||||
impl Payload for GetAddr {
|
||||
fn version() -> u32 {
|
||||
60002
|
||||
0
|
||||
}
|
||||
|
||||
fn command() -> &'static str {
|
||||
|
|
|
@ -16,6 +16,6 @@ pub struct Config {
|
|||
pub peers: Vec<SocketAddr>,
|
||||
/// Connect to these nodes to retrieve peer addresses, and disconnect.
|
||||
pub seeds: Vec<String>,
|
||||
/// p2p module cache directory.
|
||||
/// p2p/nodes.csv file path
|
||||
pub node_table_path: PathBuf,
|
||||
}
|
||||
|
|
|
@ -11,9 +11,9 @@ pub fn start(cfg: config::Config) -> Result<(), String> {
|
|||
try!(init_db(&cfg, &db));
|
||||
|
||||
let p2p_cfg = p2p::Config {
|
||||
threads: 4,
|
||||
inbound_connections: 10,
|
||||
outbound_connections: 10,
|
||||
threads: cfg.p2p_threads,
|
||||
inbound_connections: cfg.inbound_connections,
|
||||
outbound_connections: cfg.outbound_connections,
|
||||
connection: p2p::NetConfig {
|
||||
protocol_version: PROTOCOL_VERSION,
|
||||
protocol_minimum: PROTOCOL_MINIMUM,
|
||||
|
|
|
@ -8,6 +8,9 @@ pub struct Config {
|
|||
pub connect: Option<net::SocketAddr>,
|
||||
pub seednode: Option<String>,
|
||||
pub print_to_console: bool,
|
||||
pub inbound_connections: u32,
|
||||
pub outbound_connections: u32,
|
||||
pub p2p_threads: usize,
|
||||
}
|
||||
|
||||
pub fn parse(matches: &clap::ArgMatches) -> Result<Config, String> {
|
||||
|
@ -19,6 +22,16 @@ pub fn parse(matches: &clap::ArgMatches) -> Result<Config, String> {
|
|||
(true, true) => return Err("Only one testnet option can be used".into()),
|
||||
};
|
||||
|
||||
let (in_connections, out_connections) = match magic {
|
||||
Magic::Testnet | Magic::Mainnet => (10, 10),
|
||||
Magic::Regtest => (1, 0),
|
||||
};
|
||||
|
||||
let p2p_threads = match magic {
|
||||
Magic::Testnet | Magic::Mainnet => 4,
|
||||
Magic::Regtest => 1,
|
||||
};
|
||||
|
||||
let port = match matches.value_of("port") {
|
||||
Some(port) => try!(port.parse().map_err(|_| "Invalid port".to_owned())),
|
||||
None => magic.port(),
|
||||
|
@ -45,6 +58,9 @@ pub fn parse(matches: &clap::ArgMatches) -> Result<Config, String> {
|
|||
port: port,
|
||||
connect: connect,
|
||||
seednode: seednode,
|
||||
inbound_connections: in_connections,
|
||||
outbound_connections: out_connections,
|
||||
p2p_threads: p2p_threads,
|
||||
};
|
||||
|
||||
Ok(config)
|
||||
|
|
|
@ -34,7 +34,6 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
fn run() -> Result<(), String> {
|
||||
let yaml = load_yaml!("cli.yml");
|
||||
let matches = clap::App::from_yaml(yaml).get_matches();
|
||||
|
|
Loading…
Reference in New Issue