Tidy up CLI options and make JSONRPC & webapps on by default. (#1045)

* Tidy up CLI options and make JSONRPC & webapps on by default.

* Fix test.
This commit is contained in:
Gav Wood 2016-05-04 22:44:42 +02:00
parent ad00bd7bc8
commit 0d507922ce
3 changed files with 39 additions and 25 deletions

View File

@ -59,7 +59,7 @@ Networking Options:
string or input to SHA3 operation.
API and Console Options:
-j --jsonrpc Enable the JSON-RPC API server.
--jsonrpc-off Disable the JSON-RPC API server.
--jsonrpc-port PORT Specify the port portion of the JSONRPC API server
[default: 8545].
--jsonrpc-interface IP Specify the hostname portion of the JSONRPC API
@ -68,10 +68,18 @@ API and Console Options:
--jsonrpc-cors URL Specify CORS header for JSON-RPC API responses.
--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.
name. Possible name are web3, eth, net, personal,
ethcore, traces.
[default: web3,eth,net,personal,ethcore,traces].
-w --webapp Enable the web applications server (e.g.
status page).
--ipc-off Disable JSON-RPC over IPC service.
--ipc-path PATH Specify custom path for JSON-RPC over IPC service
[default: $HOME/.parity/jsonrpc.ipc].
--ipc-apis APIS Specify custom API set available via JSON-RPC over
IPC [default: web3,eth,net,personal,ethcore].
--webapp-off Disable the web applications server (e.g. status
page).
--webapp-port PORT Specify the port portion of the WebApps server
[default: 8080].
--webapp-interface IP Specify the hostname portion of the WebApps
@ -84,12 +92,6 @@ API and Console Options:
--webapp-pass PASSWORD Specify password for WebApps server. Use only in
conjunction with --webapp-user.
--ipc-disable Disable JSON-RPC over IPC service
--ipc-path PATH Specify custom path for IPC service
[default: $HOME/.parity/jsonrpc.ipc]
--ipc-api APIS Specify custom API set available via IPC service
[default: web3,eth,net,personal,ethcore]
Sealing/Mining Options:
--force-sealing Force the node to author new blocks as if it were
always sealing/mining.
@ -133,18 +135,23 @@ Footprint Options:
the entire system, overrides other cache and queue
options.
Geth-compatibility Options:
Legacy Options:
--datadir PATH Equivalent to --db-path PATH.
--testnet Equivalent to --chain testnet.
--networkid INDEX Equivalent to --network-id INDEX.
--maxpeers COUNT Equivalent to --peers COUNT.
--nodekey KEY Equivalent to --node-key KEY.
--nodiscover Equivalent to --no-discovery.
--rpc Equivalent to --jsonrpc.
-j --jsonrpc Does nothing; JSON-RPC is on by default now.
-w --webapp Does nothing; web app server is on by default now.
--rpc Does nothing; JSON-RPC is on by default now.
--rpcaddr IP Equivalent to --jsonrpc-interface IP.
--rpcport PORT Equivalent to --jsonrpc-port PORT.
--rpcapi APIS Equivalent to --jsonrpc-apis APIS.
--rpccorsdomain URL Equivalent to --jsonrpc-cors URL.
--ipcdisable Equivalent to --ipc-off.
--ipcapi APIS Equivalent to --ipc-apis APIS.
--ipcpath PATH Equivalent to --ipc-path PATH.
--gasprice WEI Minimum amount of Wei per GAS to be paid for a
transaction to be accepted for mining. Overrides
--basic-tx-usd.
@ -184,12 +191,15 @@ pub struct Args {
pub flag_cache_pref_size: usize,
pub flag_cache_max_size: usize,
pub flag_queue_max_size: usize,
pub flag_jsonrpc: bool,
pub flag_jsonrpc_off: bool,
pub flag_jsonrpc_interface: String,
pub flag_jsonrpc_port: u16,
pub flag_jsonrpc_cors: Option<String>,
pub flag_jsonrpc_apis: String,
pub flag_webapp: bool,
pub flag_ipc_off: bool,
pub flag_ipc_path: String,
pub flag_ipc_apis: String,
pub flag_webapp_off: bool,
pub flag_webapp_port: u16,
pub flag_webapp_interface: String,
pub flag_webapp_user: Option<String>,
@ -203,10 +213,7 @@ pub struct Args {
pub flag_tx_limit: usize,
pub flag_logging: Option<String>,
pub flag_version: bool,
pub flag_ipc_disable: bool,
pub flag_ipc_path: String,
pub flag_ipc_api: String,
// geth-compatibility...
// legacy...
pub flag_nodekey: Option<String>,
pub flag_nodiscover: bool,
pub flag_maxpeers: Option<usize>,
@ -214,6 +221,8 @@ pub struct Args {
pub flag_extradata: Option<String>,
pub flag_etherbase: Option<String>,
pub flag_gasprice: Option<String>,
pub flag_jsonrpc: bool,
pub flag_webapp: bool,
pub flag_rpc: bool,
pub flag_rpcaddr: Option<String>,
pub flag_rpcport: Option<u16>,
@ -221,6 +230,9 @@ pub struct Args {
pub flag_rpcapi: Option<String>,
pub flag_testnet: bool,
pub flag_networkid: Option<String>,
pub flag_ipcdisable: bool,
pub flag_ipcpath: Option<String>,
pub flag_ipcapi: Option<String>,
}
pub fn print_version() {

View File

@ -269,20 +269,21 @@ impl Configuration {
pub fn ipc_settings(&self) -> IpcConfiguration {
IpcConfiguration {
enabled: !self.args.flag_ipc_disable,
socket_addr: self.args.flag_ipc_path.clone()
enabled: !(self.args.flag_ipcdisable || self.args.flag_ipc_off),
socket_addr: self.args.flag_ipcpath.clone().unwrap_or(self.args.flag_ipc_path.clone())
.replace("$HOME", env::home_dir().unwrap().to_str().unwrap()),
apis: self.args.flag_ipc_api.clone(),
apis: self.args.flag_ipcapi.clone().unwrap_or(self.args.flag_ipc_apis.clone()),
}
}
pub fn network_settings(&self) -> NetworkSettings {
if self.args.flag_jsonrpc { println!("WARNING: Flag -j/--json-rpc is deprecated. JSON-RPC is now on by default. Ignoring."); }
NetworkSettings {
name: self.args.flag_identity.clone(),
chain: self.chain(),
max_peers: self.max_peers(),
network_port: self.net_port(),
rpc_enabled: self.args.flag_rpc || self.args.flag_jsonrpc,
rpc_enabled: !self.args.flag_jsonrpc_off,
rpc_interface: self.args.flag_rpcaddr.clone().unwrap_or(self.args.flag_jsonrpc_interface.clone()),
rpc_port: self.args.flag_rpcport.unwrap_or(self.args.flag_jsonrpc_port),
}
@ -315,7 +316,7 @@ mod tests {
chain: "morden".to_owned(),
max_peers: 25,
network_port: 30303,
rpc_enabled: false,
rpc_enabled: true,
rpc_interface: "local".to_owned(),
rpc_port: 8545,
});

View File

@ -181,10 +181,11 @@ fn execute_client(conf: Configuration) {
}, &dependencies);
// setup ipc rpc
let ipc_server = rpc::new_ipc(conf.ipc_settings(), &dependencies);
let _ipc_server = rpc::new_ipc(conf.ipc_settings(), &dependencies);
if conf.args.flag_webapp { println!("WARNING: Flag -w/--webapp is deprecated. Web app server is now on by default. Ignoring."); }
let webapp_server = webapp::new(webapp::Configuration {
enabled: conf.args.flag_webapp,
enabled: !conf.args.flag_webapp_off,
interface: conf.args.flag_webapp_interface.clone(),
port: conf.args.flag_webapp_port,
user: conf.args.flag_webapp_user.clone(),