You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
560 B

  1. package rpc
  2. type RPCRequest struct {
  3. JSONRPC string `json:"jsonrpc"`
  4. Method string `json:"method"`
  5. Params []interface{} `json:"params"`
  6. Id int `json:"id"`
  7. }
  8. type RPCResponse struct {
  9. Result interface{} `json:"result"`
  10. Error string `json:"error"`
  11. Id string `json:"id"`
  12. JSONRPC string `json:"jsonrpc"`
  13. }
  14. func NewRPCResponse(res interface{}, err string) RPCResponse {
  15. if res == nil {
  16. res = struct{}{}
  17. }
  18. return RPCResponse{
  19. Result: res,
  20. Error: err,
  21. Id: "",
  22. JSONRPC: "2.0",
  23. }
  24. }