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.

33 lines
722 B

  1. package rpctypes
  2. type RPCRequest struct {
  3. JSONRPC string `json:"jsonrpc"`
  4. Id string `json:"id"`
  5. Method string `json:"method"`
  6. Params []interface{} `json:"params"`
  7. }
  8. type RPCResponse struct {
  9. JSONRPC string `json:"jsonrpc"`
  10. Id string `json:"id"`
  11. Result interface{} `json:"result"`
  12. Error string `json:"error"`
  13. }
  14. func NewRPCResponse(id string, res interface{}, err string) RPCResponse {
  15. if res == nil {
  16. res = struct{}{}
  17. }
  18. return RPCResponse{
  19. JSONRPC: "2.0",
  20. Id: id,
  21. Result: res,
  22. Error: err,
  23. }
  24. }
  25. // Goes in the Result field of an RPCResponse.
  26. type RPCEventResult struct {
  27. Event string `json:"event"`
  28. Data interface{} `json:"data"`
  29. }