gen_newmessage_json.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 _ = (*newMessageOverride)(nil)
  8. // MarshalJSON marshals type NewMessage to a json string
  9. func (n NewMessage) MarshalJSON() ([]byte, error) {
  10. type NewMessage struct {
  11. SymKeyID string `json:"symKeyID"`
  12. PublicKey hexutil.Bytes `json:"pubKey"`
  13. Sig string `json:"sig"`
  14. TTL uint32 `json:"ttl"`
  15. Topic TopicType `json:"topic"`
  16. Payload hexutil.Bytes `json:"payload"`
  17. Padding hexutil.Bytes `json:"padding"`
  18. PowTime uint32 `json:"powTime"`
  19. PowTarget float64 `json:"powTarget"`
  20. TargetPeer string `json:"targetPeer"`
  21. }
  22. var enc NewMessage
  23. enc.SymKeyID = n.SymKeyID
  24. enc.PublicKey = n.PublicKey
  25. enc.Sig = n.Sig
  26. enc.TTL = n.TTL
  27. enc.Topic = n.Topic
  28. enc.Payload = n.Payload
  29. enc.Padding = n.Padding
  30. enc.PowTime = n.PowTime
  31. enc.PowTarget = n.PowTarget
  32. enc.TargetPeer = n.TargetPeer
  33. return json.Marshal(&enc)
  34. }
  35. // UnmarshalJSON unmarshals type NewMessage to a json string
  36. func (n *NewMessage) UnmarshalJSON(input []byte) error {
  37. type NewMessage struct {
  38. SymKeyID *string `json:"symKeyID"`
  39. PublicKey *hexutil.Bytes `json:"pubKey"`
  40. Sig *string `json:"sig"`
  41. TTL *uint32 `json:"ttl"`
  42. Topic *TopicType `json:"topic"`
  43. Payload *hexutil.Bytes `json:"payload"`
  44. Padding *hexutil.Bytes `json:"padding"`
  45. PowTime *uint32 `json:"powTime"`
  46. PowTarget *float64 `json:"powTarget"`
  47. TargetPeer *string `json:"targetPeer"`
  48. }
  49. var dec NewMessage
  50. if err := json.Unmarshal(input, &dec); err != nil {
  51. return err
  52. }
  53. if dec.SymKeyID != nil {
  54. n.SymKeyID = *dec.SymKeyID
  55. }
  56. if dec.PublicKey != nil {
  57. n.PublicKey = *dec.PublicKey
  58. }
  59. if dec.Sig != nil {
  60. n.Sig = *dec.Sig
  61. }
  62. if dec.TTL != nil {
  63. n.TTL = *dec.TTL
  64. }
  65. if dec.Topic != nil {
  66. n.Topic = *dec.Topic
  67. }
  68. if dec.Payload != nil {
  69. n.Payload = *dec.Payload
  70. }
  71. if dec.Padding != nil {
  72. n.Padding = *dec.Padding
  73. }
  74. if dec.PowTime != nil {
  75. n.PowTime = *dec.PowTime
  76. }
  77. if dec.PowTarget != nil {
  78. n.PowTarget = *dec.PowTarget
  79. }
  80. if dec.TargetPeer != nil {
  81. n.TargetPeer = *dec.TargetPeer
  82. }
  83. return nil
  84. }