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.

process.go 895B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package atto
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. )
  6. type process struct {
  7. Action string `json:"action"`
  8. JsonBlock string `json:"json_block"`
  9. SubType string `json:"subtype"`
  10. Block Block `json:"block"`
  11. }
  12. type processResponse struct {
  13. Error string `json:"error"`
  14. }
  15. func doProcessRPC(process process, node string) error {
  16. var requestBody, responseBytes []byte
  17. requestBody, err := json.Marshal(process)
  18. if err != nil {
  19. return err
  20. }
  21. responseBytes, err = doRPC(string(requestBody), node)
  22. if err != nil {
  23. return err
  24. }
  25. var processResponse processResponse
  26. if err = json.Unmarshal(responseBytes, &processResponse); err != nil {
  27. return err
  28. }
  29. // Need to check processResponse.Error because of
  30. // https://github.com/nanocurrency/nano-node/issues/1782.
  31. if processResponse.Error != "" {
  32. err = fmt.Errorf("could not publish block: %s", processResponse.Error)
  33. }
  34. return err
  35. }