Merge pull request #666 from ethcore/moregethcli
More geth compatibility.
This commit is contained in:
commit
22d1def894
118
parity/main.rs
118
parity/main.rs
@ -37,7 +37,7 @@ extern crate rpassword;
|
|||||||
#[cfg(feature = "rpc")]
|
#[cfg(feature = "rpc")]
|
||||||
extern crate ethcore_rpc as rpc;
|
extern crate ethcore_rpc as rpc;
|
||||||
|
|
||||||
use std::net::{SocketAddr};
|
use std::net::{SocketAddr, IpAddr};
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
@ -71,28 +71,26 @@ Parity. Ethereum Client.
|
|||||||
Copyright 2015, 2016 Ethcore (UK) Limited
|
Copyright 2015, 2016 Ethcore (UK) Limited
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
parity daemon <pid-file> [options] [ --no-bootstrap | <enode>... ]
|
parity daemon <pid-file> [options]
|
||||||
parity account (new | list)
|
parity account (new | list)
|
||||||
parity [options] [ --no-bootstrap | <enode>... ]
|
parity [options]
|
||||||
|
|
||||||
Protocol Options:
|
Protocol Options:
|
||||||
--chain CHAIN Specify the blockchain type. CHAIN may be either a JSON chain specification file
|
--chain CHAIN Specify the blockchain type. CHAIN may be either a JSON chain specification file
|
||||||
or olympic, frontier, homestead, mainnet, morden, or testnet [default: homestead].
|
or olympic, frontier, homestead, mainnet, morden, or testnet [default: homestead].
|
||||||
--testnet Equivalent to --chain testnet (geth-compatible).
|
--db-path PATH Specify the database & configuration directory path [default: $HOME/.parity]
|
||||||
--networkid INDEX Override the network identifier from the chain we are on.
|
|
||||||
--pruning Client should prune the state/storage trie.
|
--pruning Client should prune the state/storage trie.
|
||||||
-d --datadir PATH Specify the database & configuration directory path [default: $HOME/.parity]
|
|
||||||
--keys-path PATH Specify the path for JSON key files to be found [default: $HOME/.web3/keys]
|
--keys-path PATH Specify the path for JSON key files to be found [default: $HOME/.web3/keys]
|
||||||
--identity NAME Specify your node's name.
|
--identity NAME Specify your node's name.
|
||||||
|
|
||||||
Networking Options:
|
Networking Options:
|
||||||
--no-bootstrap Don't bother trying to connect to any nodes initially.
|
--port PORT Override the port on which the node should listen [default: 30303].
|
||||||
--listen-address URL Specify the IP/port on which to listen for peers [default: 0.0.0.0:30304].
|
|
||||||
--public-address URL Specify the IP/port on which peers may connect.
|
|
||||||
--address URL Equivalent to --listen-address URL --public-address URL.
|
|
||||||
--peers NUM Try to maintain that many peers [default: 25].
|
--peers NUM Try to maintain that many peers [default: 25].
|
||||||
|
--nat METHOD Specify method to use for determining public address. Must be one of: any, none,
|
||||||
|
upnp, extip:(IP) [default: any].
|
||||||
|
--bootnodes NODES Specify additional comma-separated bootnodes.
|
||||||
|
--no-bootstrap Don't bother trying to connect to standard bootnodes.
|
||||||
--no-discovery Disable new peer discovery.
|
--no-discovery Disable new peer discovery.
|
||||||
--no-upnp Disable trying to figure out the correct public adderss over UPnP.
|
|
||||||
--node-key KEY Specify node secret key, either as 64-character hex string or input to SHA3 operation.
|
--node-key KEY Specify node secret key, either as 64-character hex string or input to SHA3 operation.
|
||||||
|
|
||||||
API and Console Options:
|
API and Console Options:
|
||||||
@ -102,16 +100,11 @@ API and Console Options:
|
|||||||
--jsonrpc-cors URL Specify CORS header for JSON-RPC API responses [default: null].
|
--jsonrpc-cors URL Specify CORS header for JSON-RPC API responses [default: null].
|
||||||
--jsonrpc-apis APIS Specify the APIs available through the JSONRPC interface. APIS is a comma-delimited
|
--jsonrpc-apis APIS Specify the APIs available through the JSONRPC interface. APIS is a comma-delimited
|
||||||
list of API name. Possible name are web3, eth and net. [default: web3,eth,net].
|
list of API name. Possible name are web3, eth and net. [default: web3,eth,net].
|
||||||
--rpc Equivalent to --jsonrpc (geth-compatible).
|
|
||||||
--rpcaddr HOST Equivalent to --jsonrpc-addr HOST (geth-compatible).
|
|
||||||
--rpcport PORT Equivalent to --jsonrpc-port PORT (geth-compatible).
|
|
||||||
--rpcapi APIS Equivalent to --jsonrpc-apis APIS (geth-compatible).
|
|
||||||
--rpccorsdomain URL Equivalent to --jsonrpc-cors URL (geth-compatible).
|
|
||||||
|
|
||||||
Sealing/Mining Options:
|
Sealing/Mining Options:
|
||||||
--author ADDRESS Specify the block author (aka "coinbase") address for sending block rewards
|
--author ADDRESS Specify the block author (aka "coinbase") address for sending block rewards
|
||||||
from sealed blocks [default: 0037a6b811ffeb6e072da21179d11b1406371c63].
|
from sealed blocks [default: 0037a6b811ffeb6e072da21179d11b1406371c63].
|
||||||
--extradata STRING Specify a custom extra-data for authored blocks, no more than 32 characters.
|
--extra-data STRING Specify a custom extra-data for authored blocks, no more than 32 characters.
|
||||||
|
|
||||||
Memory Footprint Options:
|
Memory Footprint Options:
|
||||||
--cache-pref-size BYTES Specify the prefered size of the blockchain cache in bytes [default: 16384].
|
--cache-pref-size BYTES Specify the prefered size of the blockchain cache in bytes [default: 16384].
|
||||||
@ -120,6 +113,21 @@ Memory Footprint Options:
|
|||||||
--cache MEGABYTES Set total amount of cache to use for the entire system, mutually exclusive with
|
--cache MEGABYTES Set total amount of cache to use for the entire system, mutually exclusive with
|
||||||
other cache options (geth-compatible).
|
other cache options (geth-compatible).
|
||||||
|
|
||||||
|
Geth-Compatibility Options
|
||||||
|
--datadir PATH Equivalent to --db-path PATH.
|
||||||
|
--testnet Equivalent to --chain testnet.
|
||||||
|
--networkid INDEX Override the network identifier from the chain we are on.
|
||||||
|
--rpc Equivalent to --jsonrpc.
|
||||||
|
--rpcaddr HOST Equivalent to --jsonrpc-addr HOST.
|
||||||
|
--rpcport PORT Equivalent to --jsonrpc-port PORT.
|
||||||
|
--rpcapi APIS Equivalent to --jsonrpc-apis APIS.
|
||||||
|
--rpccorsdomain URL Equivalent to --jsonrpc-cors URL.
|
||||||
|
--maxpeers COUNT Equivalent to --peers COUNT.
|
||||||
|
--nodekey KEY Equivalent to --node-key KEY.
|
||||||
|
--nodiscover Equivalent to --no-discovery.
|
||||||
|
--etherbase ADDRESS Equivalent to --author ADDRESS.
|
||||||
|
--extradata STRING Equivalent to --extra-data STRING.
|
||||||
|
|
||||||
Miscellaneous Options:
|
Miscellaneous Options:
|
||||||
-l --logging LOGGING Specify the logging level.
|
-l --logging LOGGING Specify the logging level.
|
||||||
-v --version Show information about version.
|
-v --version Show information about version.
|
||||||
@ -133,22 +141,18 @@ struct Args {
|
|||||||
cmd_new: bool,
|
cmd_new: bool,
|
||||||
cmd_list: bool,
|
cmd_list: bool,
|
||||||
arg_pid_file: String,
|
arg_pid_file: String,
|
||||||
arg_enode: Vec<String>,
|
|
||||||
flag_chain: String,
|
flag_chain: String,
|
||||||
flag_testnet: bool,
|
flag_db_path: String,
|
||||||
flag_datadir: String,
|
|
||||||
flag_networkid: Option<String>,
|
|
||||||
flag_identity: String,
|
flag_identity: String,
|
||||||
flag_cache: Option<usize>,
|
flag_cache: Option<usize>,
|
||||||
flag_keys_path: String,
|
flag_keys_path: String,
|
||||||
|
flag_bootnodes: Option<String>,
|
||||||
flag_pruning: bool,
|
flag_pruning: bool,
|
||||||
flag_no_bootstrap: bool,
|
flag_no_bootstrap: bool,
|
||||||
flag_listen_address: String,
|
flag_port: u16,
|
||||||
flag_public_address: Option<String>,
|
|
||||||
flag_address: Option<String>,
|
|
||||||
flag_peers: usize,
|
flag_peers: usize,
|
||||||
flag_no_discovery: bool,
|
flag_no_discovery: bool,
|
||||||
flag_no_upnp: bool,
|
flag_nat: String,
|
||||||
flag_node_key: Option<String>,
|
flag_node_key: Option<String>,
|
||||||
flag_cache_pref_size: usize,
|
flag_cache_pref_size: usize,
|
||||||
flag_cache_max_size: usize,
|
flag_cache_max_size: usize,
|
||||||
@ -158,15 +162,24 @@ struct Args {
|
|||||||
flag_jsonrpc_port: u16,
|
flag_jsonrpc_port: u16,
|
||||||
flag_jsonrpc_cors: String,
|
flag_jsonrpc_cors: String,
|
||||||
flag_jsonrpc_apis: String,
|
flag_jsonrpc_apis: String,
|
||||||
|
flag_logging: Option<String>,
|
||||||
|
flag_version: bool,
|
||||||
|
// geth-compatibility...
|
||||||
|
flag_nodekey: Option<String>,
|
||||||
|
flag_nodiscover: bool,
|
||||||
|
flag_maxpeers: Option<usize>,
|
||||||
|
flag_author: String,
|
||||||
|
flag_extra_data: Option<String>,
|
||||||
|
flag_datadir: Option<String>,
|
||||||
|
flag_extradata: Option<String>,
|
||||||
|
flag_etherbase: Option<String>,
|
||||||
flag_rpc: bool,
|
flag_rpc: bool,
|
||||||
flag_rpcaddr: Option<String>,
|
flag_rpcaddr: Option<String>,
|
||||||
flag_rpcport: Option<u16>,
|
flag_rpcport: Option<u16>,
|
||||||
flag_rpccorsdomain: Option<String>,
|
flag_rpccorsdomain: Option<String>,
|
||||||
flag_rpcapi: Option<String>,
|
flag_rpcapi: Option<String>,
|
||||||
flag_logging: Option<String>,
|
flag_testnet: bool,
|
||||||
flag_version: bool,
|
flag_networkid: Option<String>,
|
||||||
flag_author: String,
|
|
||||||
flag_extra_data: Option<String>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_log(init: &Option<String>) {
|
fn setup_log(init: &Option<String>) {
|
||||||
@ -246,15 +259,17 @@ impl Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn path(&self) -> String {
|
fn path(&self) -> String {
|
||||||
self.args.flag_datadir.replace("$HOME", env::home_dir().unwrap().to_str().unwrap())
|
let d = self.args.flag_datadir.as_ref().unwrap_or(&self.args.flag_db_path);
|
||||||
|
d.replace("$HOME", env::home_dir().unwrap().to_str().unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn author(&self) -> Address {
|
fn author(&self) -> Address {
|
||||||
Address::from_str(&self.args.flag_author).unwrap_or_else(|_| die!("{}: Invalid address for --author. Must be 40 hex characters, without the 0x at the beginning.", self.args.flag_author))
|
let d = self.args.flag_etherbase.as_ref().unwrap_or(&self.args.flag_author);
|
||||||
|
Address::from_str(d).unwrap_or_else(|_| die!("{}: Invalid address for --author. Must be 40 hex characters, without the 0x at the beginning.", self.args.flag_author))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extra_data(&self) -> Bytes {
|
fn extra_data(&self) -> Bytes {
|
||||||
match self.args.flag_extra_data {
|
match self.args.flag_extradata.as_ref().or(self.args.flag_extra_data.as_ref()) {
|
||||||
Some(ref x) if x.len() <= 32 => x.as_bytes().to_owned(),
|
Some(ref x) if x.len() <= 32 => x.as_bytes().to_owned(),
|
||||||
None => version_data(),
|
None => version_data(),
|
||||||
Some(ref x) => { die!("{}: Extra data must be at most 32 characters.", x); }
|
Some(ref x) => { die!("{}: Extra data must be at most 32 characters.", x); }
|
||||||
@ -286,45 +301,36 @@ impl Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn init_nodes(&self, spec: &Spec) -> Vec<String> {
|
fn init_nodes(&self, spec: &Spec) -> Vec<String> {
|
||||||
if self.args.flag_no_bootstrap { Vec::new() } else {
|
let mut r = if self.args.flag_no_bootstrap { Vec::new() } else { spec.nodes().clone() };
|
||||||
match self.args.arg_enode.len() {
|
if let Some(ref x) = self.args.flag_bootnodes {
|
||||||
0 => spec.nodes().clone(),
|
r.extend(x.split(",").map(|s| Self::normalize_enode(s).unwrap_or_else(|| die!("{}: Invalid node address format given for a boot node.", s))));
|
||||||
_ => self.args.arg_enode.iter().map(|s| Self::normalize_enode(s).unwrap_or_else(||die!("{}: Invalid node address format given for a boot node.", s))).collect(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
r
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature="dev", allow(useless_format))]
|
#[cfg_attr(feature="dev", allow(useless_format))]
|
||||||
fn net_addresses(&self) -> (Option<SocketAddr>, Option<SocketAddr>) {
|
fn net_addresses(&self) -> (Option<SocketAddr>, Option<SocketAddr>) {
|
||||||
let mut listen_address = None;
|
let listen_address = Some(SocketAddr::new(IpAddr::from_str("0.0.0.0").unwrap(), self.args.flag_port));
|
||||||
let mut public_address = None;
|
let public_address = if self.args.flag_nat.starts_with("extip:") {
|
||||||
|
let host = &self.args.flag_nat[6..];
|
||||||
if let Some(ref a) = self.args.flag_address {
|
let host = IpAddr::from_str(host).unwrap_or_else(|_| die!("Invalid host given with `--nat extip:{}`", host));
|
||||||
public_address = Some(SocketAddr::from_str(a.as_ref()).unwrap_or_else(|_| die!("{}: Invalid listen/public address given with --address", a)));
|
Some(SocketAddr::new(host, self.args.flag_port))
|
||||||
listen_address = public_address;
|
} else {
|
||||||
}
|
listen_address.clone()
|
||||||
if listen_address.is_none() {
|
};
|
||||||
listen_address = Some(SocketAddr::from_str(self.args.flag_listen_address.as_ref()).unwrap_or_else(|_| die!("{}: Invalid listen/public address given with --listen-address", self.args.flag_listen_address)));
|
|
||||||
}
|
|
||||||
if let Some(ref a) = self.args.flag_public_address {
|
|
||||||
if public_address.is_some() {
|
|
||||||
die!("Conflicting flags provided: --address and --public-address");
|
|
||||||
}
|
|
||||||
public_address = Some(SocketAddr::from_str(a.as_ref()).unwrap_or_else(|_| die!("{}: Invalid listen/public address given with --public-address", a)));
|
|
||||||
}
|
|
||||||
(listen_address, public_address)
|
(listen_address, public_address)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn net_settings(&self, spec: &Spec) -> NetworkConfiguration {
|
fn net_settings(&self, spec: &Spec) -> NetworkConfiguration {
|
||||||
let mut ret = NetworkConfiguration::new();
|
let mut ret = NetworkConfiguration::new();
|
||||||
ret.nat_enabled = !self.args.flag_no_upnp;
|
ret.nat_enabled = self.args.flag_nat == "any" || self.args.flag_nat == "upnp";
|
||||||
ret.boot_nodes = self.init_nodes(spec);
|
ret.boot_nodes = self.init_nodes(spec);
|
||||||
let (listen, public) = self.net_addresses();
|
let (listen, public) = self.net_addresses();
|
||||||
ret.listen_address = listen;
|
ret.listen_address = listen;
|
||||||
ret.public_address = public;
|
ret.public_address = public;
|
||||||
ret.use_secret = self.args.flag_node_key.as_ref().map(|s| Secret::from_str(&s).unwrap_or_else(|_| s.sha3()));
|
ret.use_secret = self.args.flag_node_key.as_ref().map(|s| Secret::from_str(&s).unwrap_or_else(|_| s.sha3()));
|
||||||
ret.discovery_enabled = !self.args.flag_no_discovery;
|
ret.discovery_enabled = !self.args.flag_no_discovery && !self.args.flag_nodiscover;
|
||||||
ret.ideal_peers = self.args.flag_peers as u32;
|
ret.ideal_peers = self.args.flag_maxpeers.unwrap_or(self.args.flag_peers) as u32;
|
||||||
let mut net_path = PathBuf::from(&self.path());
|
let mut net_path = PathBuf::from(&self.path());
|
||||||
net_path.push("network");
|
net_path.push("network");
|
||||||
ret.config_path = Some(net_path.to_str().unwrap().to_owned());
|
ret.config_path = Some(net_path.to_str().unwrap().to_owned());
|
||||||
|
Loading…
Reference in New Issue
Block a user