add new command line options: ws, wsbind, and wsapi
new command line options: --ws Enable the Websocket JSON-RPC server --wsbind:<value> Set address:port pair(s) (comma-separated) Websocket JSON-RPC server will bind to (default: localhost:8546) --wsapi:<value> Enable specific set of Websocket RPC API from list (comma-separated) (available: eth, debug) fixes #770
This commit is contained in:
parent
6015a4e029
commit
c142119487
|
@ -126,6 +126,7 @@ type
|
||||||
prune*: PruneMode
|
prune*: PruneMode
|
||||||
graphql*: GraphqlConfiguration
|
graphql*: GraphqlConfiguration
|
||||||
rpc*: RpcConfiguration ## JSON-RPC configuration
|
rpc*: RpcConfiguration ## JSON-RPC configuration
|
||||||
|
ws*: RpcConfiguration ## Websocket JSON-RPC configuration
|
||||||
net*: NetConfiguration ## Network configuration
|
net*: NetConfiguration ## Network configuration
|
||||||
debug*: DebugConfiguration ## Debug configuration
|
debug*: DebugConfiguration ## Debug configuration
|
||||||
customGenesis*: CustomGenesis ## Custom Genesis Configuration
|
customGenesis*: CustomGenesis ## Custom Genesis Configuration
|
||||||
|
@ -462,6 +463,27 @@ proc processGraphqlArguments(key, value: string): ConfigStatus =
|
||||||
else:
|
else:
|
||||||
result = EmptyOption
|
result = EmptyOption
|
||||||
|
|
||||||
|
proc processWsArguments(key, value: string): ConfigStatus =
|
||||||
|
## Processes only `Websocket RPC` related command line options
|
||||||
|
result = Success
|
||||||
|
let config = getConfiguration()
|
||||||
|
let skey = key.toLowerAscii()
|
||||||
|
if skey == "ws":
|
||||||
|
if RpcFlags.Enabled notin config.ws.flags:
|
||||||
|
config.ws.flags.incl(RpcFlags.Enabled)
|
||||||
|
config.ws.flags.incl(defaultRpcApi)
|
||||||
|
elif skey == "wsbind":
|
||||||
|
config.ws.binds.setLen(0)
|
||||||
|
result = processAddressPortsList(value, config.ws.binds)
|
||||||
|
elif skey == "wsapi":
|
||||||
|
if RpcFlags.Enabled in config.ws.flags:
|
||||||
|
config.ws.flags.excl(defaultRpcApi)
|
||||||
|
else:
|
||||||
|
config.ws.flags.incl(RpcFlags.Enabled)
|
||||||
|
result = processRpcApiList(value, config.ws.flags)
|
||||||
|
else:
|
||||||
|
result = EmptyOption
|
||||||
|
|
||||||
proc setBootnodes(onodes: var seq[ENode], nodeUris: openarray[string]) =
|
proc setBootnodes(onodes: var seq[ENode], nodeUris: openarray[string]) =
|
||||||
var node: ENode
|
var node: ENode
|
||||||
onodes = newSeqOfCap[ENode](nodeUris.len)
|
onodes = newSeqOfCap[ENode](nodeUris.len)
|
||||||
|
@ -677,6 +699,10 @@ proc initConfiguration(): NimbusConfiguration =
|
||||||
result.rpc.flags = {}
|
result.rpc.flags = {}
|
||||||
result.rpc.binds = @[initTAddress("127.0.0.1:8545")]
|
result.rpc.binds = @[initTAddress("127.0.0.1:8545")]
|
||||||
|
|
||||||
|
## Websocket RPC defaults
|
||||||
|
result.ws.flags = {}
|
||||||
|
result.ws.binds = @[initTAddress("127.0.0.1:8546")]
|
||||||
|
|
||||||
## Network defaults
|
## Network defaults
|
||||||
result.net.setNetwork(defaultNetwork)
|
result.net.setNetwork(defaultNetwork)
|
||||||
result.net.maxPeers = 25
|
result.net.maxPeers = 25
|
||||||
|
@ -765,6 +791,9 @@ LOCAL SERVICE OPTIONS:
|
||||||
--rpcapi:<value> Enable specific set of RPC API from list (comma-separated) (available: eth, debug)
|
--rpcapi:<value> Enable specific set of RPC API from list (comma-separated) (available: eth, debug)
|
||||||
--graphql Enable the HTTP-GraphQL server
|
--graphql Enable the HTTP-GraphQL server
|
||||||
--graphqlbind:<value> Set address:port pair GraphQL server will bind (default: localhost:8547)
|
--graphqlbind:<value> Set address:port pair GraphQL server will bind (default: localhost:8547)
|
||||||
|
--ws Enable the Websocket JSON-RPC server
|
||||||
|
--wsbind:<value> Set address:port pair(s) (comma-separated) Websocket JSON-RPC server will bind to (default: localhost:8546)
|
||||||
|
--wsapi:<value> Enable specific set of Websocket RPC API from list (comma-separated) (available: eth, debug)
|
||||||
|
|
||||||
LOGGING AND DEBUGGING OPTIONS:
|
LOGGING AND DEBUGGING OPTIONS:
|
||||||
--log-level:<value> One of: $2 (default: $3)
|
--log-level:<value> One of: $2 (default: $3)
|
||||||
|
@ -812,6 +841,7 @@ when declared(os.paramCount): # not available with `--app:lib`
|
||||||
processArgument processNetArguments, key, value, msg
|
processArgument processNetArguments, key, value, msg
|
||||||
processArgument processDebugArguments, key, value, msg
|
processArgument processDebugArguments, key, value, msg
|
||||||
processArgument processGraphqlArguments, key, value, msg
|
processArgument processGraphqlArguments, key, value, msg
|
||||||
|
processArgument processWsArguments, key, value, msg
|
||||||
if result != Success:
|
if result != Success:
|
||||||
msg = "Unknown option: '" & key & "'."
|
msg = "Unknown option: '" & key & "'."
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue