diff --git a/rpc/jsonrpc.go b/rpc/jsonrpc.go index 4a28c4b13447de5dabb98fd10767be1b263a2d99..73cb0cb6b78862227ecc27afb98bc1f7423244c7 100644 --- a/rpc/jsonrpc.go +++ b/rpc/jsonrpc.go @@ -40,7 +40,9 @@ type ( // RPCResponse MUST follow the JSON-RPC specification for Response object // reference: http://www.jsonrpc.org/specification#response_object - RPCResponse interface{} + RPCResponse interface { + AssertIsRPCResponse() bool + } // RPCResultResponse MUST NOT contain the error member if no error occurred RPCResultResponse struct { @@ -82,3 +84,15 @@ func NewRPCErrorResponse(id string, code int, message string) RPCResponse { JSONRPC: "2.0", }) } + +// AssertIsRPCResponse implements a marker method for RPCResultResponse +// to implement the interface RPCResponse +func (rpcResultResponse *RPCResultResponse) AssertIsRPCResponse() bool { + return true +} + +// AssertIsRPCResponse implements a marker method for RPCErrorResponse +// to implement the interface RPCResponse +func (rpcErrorResponse *RPCErrorResponse) AssertIsRPCResponse() bool { + return true +}