gen_message_json.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Code generated by github.com/fjl/gencodec. DO NOT EDIT.
  2. package whisperv6
  3. import (
  4. "encoding/json"
  5. "github.com/ethereum/go-ethereum/common/hexutil"
  6. )
  7. var _ = (*messageOverride)(nil)
  8. func (m Message) MarshalJSON() ([]byte, error) {
  9. type Message struct {
  10. Sig hexutil.Bytes `json:"sig,omitempty"`
  11. TTL uint32 `json:"ttl"`
  12. Timestamp uint32 `json:"timestamp"`
  13. Topic TopicType `json:"topic"`
  14. Payload hexutil.Bytes `json:"payload"`
  15. Padding hexutil.Bytes `json:"padding"`
  16. PoW float64 `json:"pow"`
  17. Hash hexutil.Bytes `json:"hash"`
  18. Dst hexutil.Bytes `json:"recipientPublicKey,omitempty"`
  19. }
  20. var enc Message
  21. enc.Sig = m.Sig
  22. enc.TTL = m.TTL
  23. enc.Timestamp = m.Timestamp
  24. enc.Topic = m.Topic
  25. enc.Payload = m.Payload
  26. enc.Padding = m.Padding
  27. enc.PoW = m.PoW
  28. enc.Hash = m.Hash
  29. enc.Dst = m.Dst
  30. return json.Marshal(&enc)
  31. }
  32. func (m *Message) UnmarshalJSON(input []byte) error {
  33. type Message struct {
  34. Sig *hexutil.Bytes `json:"sig,omitempty"`
  35. TTL *uint32 `json:"ttl"`
  36. Timestamp *uint32 `json:"timestamp"`
  37. Topic *TopicType `json:"topic"`
  38. Payload *hexutil.Bytes `json:"payload"`
  39. Padding *hexutil.Bytes `json:"padding"`
  40. PoW *float64 `json:"pow"`
  41. Hash *hexutil.Bytes `json:"hash"`
  42. Dst *hexutil.Bytes `json:"recipientPublicKey,omitempty"`
  43. }
  44. var dec Message
  45. if err := json.Unmarshal(input, &dec); err != nil {
  46. return err
  47. }
  48. if dec.Sig != nil {
  49. m.Sig = *dec.Sig
  50. }
  51. if dec.TTL != nil {
  52. m.TTL = *dec.TTL
  53. }
  54. if dec.Timestamp != nil {
  55. m.Timestamp = *dec.Timestamp
  56. }
  57. if dec.Topic != nil {
  58. m.Topic = *dec.Topic
  59. }
  60. if dec.Payload != nil {
  61. m.Payload = *dec.Payload
  62. }
  63. if dec.Padding != nil {
  64. m.Padding = *dec.Padding
  65. }
  66. if dec.PoW != nil {
  67. m.PoW = *dec.PoW
  68. }
  69. if dec.Hash != nil {
  70. m.Hash = *dec.Hash
  71. }
  72. if dec.Dst != nil {
  73. m.Dst = *dec.Dst
  74. }
  75. return nil
  76. }