Skip to content

JsonRpcServer

The JSON-RPC interface is implemented using a JsonRpcServer actor which handles the new incoming connections and spawns a JsonRpc actor for each new connection.

The JsonRpc actor handles the JSON-RPC protocol, parses the input stream as JSON-RPC, executes the request and generates an appropriate response.

The supported JSON-RPC methods are implemented in json_rpc_methods.rs.

See JSON-RPC for further information.

API

The JsonRpcServer does not expose any public API, once it is started it will read the necessary parameters from the ConfigManager and automatically handle all the incoming connections.

Incoming: Others -> JsonRpcServer

These are the messages supported by the JsonRpcServer:

Message Input type Output type Description
InboundTcpConnect TcpStream () Request to create a session from an incoming TCP connection
Unregister Addr<JsonRpc> () Removes a closed connection from the list of open connections

However, they are internal messages: the InboundTcpConnect is sent by the stream listener and the Unregister is sent by the JsonRpc actor.

Outgoing messages: JsonRpcServer -> Others

These are the messages sent by the EpochManager:

Message Destination Input type Output type Description
GetConfig ConfigManager () Result<Config, io::Error> Request the configuration

GetConfig

This message is sent to the ConfigManager actor when the JsonRpcServer actor is started.

The return value is used to initialize the protocol constants (checkpoint period and epoch zero timestamp). For further information, see ConfigManager.

Incoming: Others -> JsonRpc

The JsonRpc actor does not have any message handlers.

Outgoing messages: JsonRpc -> Others

Message Destination Input type Output type Description
Unregister JsonRpcServer Addr<JsonRpc> () Removes a closed connection from the list of open connections

The JsonRpc actor only sends one Unregister message to its parent when the connection closes.

Further information

The full source code of the JsonRpcServer can be found at server.rs.