gen_criteria_json.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Code generated by github.com/fjl/gencodec. DO NOT EDIT.
  2. package whisperv5
  3. import (
  4. "encoding/json"
  5. "github.com/ethereum/go-ethereum/common/hexutil"
  6. )
  7. func (c Criteria) MarshalJSON() ([]byte, error) {
  8. type Criteria struct {
  9. SymKeyID string `json:"symKeyID"`
  10. PrivateKeyID string `json:"privateKeyID"`
  11. Sig hexutil.Bytes `json:"sig"`
  12. MinPow float64 `json:"minPow"`
  13. Topics []TopicType `json:"topics"`
  14. AllowP2P bool `json:"allowP2P"`
  15. }
  16. var enc Criteria
  17. enc.SymKeyID = c.SymKeyID
  18. enc.PrivateKeyID = c.PrivateKeyID
  19. enc.Sig = c.Sig
  20. enc.MinPow = c.MinPow
  21. enc.Topics = c.Topics
  22. enc.AllowP2P = c.AllowP2P
  23. return json.Marshal(&enc)
  24. }
  25. func (c *Criteria) UnmarshalJSON(input []byte) error {
  26. type Criteria struct {
  27. SymKeyID *string `json:"symKeyID"`
  28. PrivateKeyID *string `json:"privateKeyID"`
  29. Sig hexutil.Bytes `json:"sig"`
  30. MinPow *float64 `json:"minPow"`
  31. Topics []TopicType `json:"topics"`
  32. AllowP2P *bool `json:"allowP2P"`
  33. }
  34. var dec Criteria
  35. if err := json.Unmarshal(input, &dec); err != nil {
  36. return err
  37. }
  38. if dec.SymKeyID != nil {
  39. c.SymKeyID = *dec.SymKeyID
  40. }
  41. if dec.PrivateKeyID != nil {
  42. c.PrivateKeyID = *dec.PrivateKeyID
  43. }
  44. if dec.Sig != nil {
  45. c.Sig = dec.Sig
  46. }
  47. if dec.MinPow != nil {
  48. c.MinPow = *dec.MinPow
  49. }
  50. if dec.Topics != nil {
  51. c.Topics = dec.Topics
  52. }
  53. if dec.AllowP2P != nil {
  54. c.AllowP2P = *dec.AllowP2P
  55. }
  56. return nil
  57. }