diff --git a/nimbus/config.nim b/nimbus/config.nim index af85b780d..b45da3ea8 100644 --- a/nimbus/config.nim +++ b/nimbus/config.nim @@ -788,7 +788,7 @@ LOCAL SERVICE OPTIONS: --graphql Enable the HTTP-GraphQL server --graphqlbind: Set address:port pair GraphQL server will bind (default: localhost:8547) --ws Enable the Websocket JSON-RPC server - --wsbind: Set address:port pair(s) (comma-separated) Websocket JSON-RPC server will bind to (default: localhost:8546) + --wsbind: Set address:port pair Websocket JSON-RPC server will bind to (default: localhost:8546) --wsapi: Enable specific set of Websocket RPC API from list (comma-separated) (available: eth, debug) LOGGING AND DEBUGGING OPTIONS: diff --git a/nimbus/nimbus.nim b/nimbus/nimbus.nim index d1b4139f4..8d2ec37ea 100644 --- a/nimbus/nimbus.nim +++ b/nimbus/nimbus.nim @@ -40,6 +40,7 @@ type ethNode*: EthereumNode state*: NimbusState graphqlServer*: GraphqlHttpServerRef + wsRpcServer*: RpcWebSocketServer proc start(nimbus: NimbusNode) = var conf = getConfiguration() @@ -138,6 +139,18 @@ proc start(nimbus: NimbusNode) = if RpcFlags.Debug in conf.rpc.flags: setupDebugRpc(chainDB, nimbus.rpcServer) + # Creating Websocket RPC Server + if RpcFlags.Enabled in conf.ws.flags: + doAssert(conf.ws.binds.len > 0) + nimbus.wsRpcServer = newRpcWebSocketServer(conf.ws.binds[0]) + setupCommonRpc(nimbus.ethNode, nimbus.wsRpcServer) + + # Enable Websocket RPC APIs based on RPC flags and protocol flags + if RpcFlags.Eth in conf.ws.flags and ProtocolFlags.Eth in conf.net.protocols: + setupEthRpc(nimbus.ethNode, chainDB, nimbus.wsRpcServer) + if RpcFlags.Debug in conf.ws.flags: + setupDebugRpc(chainDB, nimbus.wsRpcServer) + ## Starting servers if RpcFlags.Enabled in conf.rpc.flags: nimbus.rpcServer.rpc("admin_quit") do() -> string: