aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv6/gen_message_json.go
diff options
context:
space:
mode:
Diffstat (limited to 'whisper/whisperv6/gen_message_json.go')
-rw-r--r--whisper/whisperv6/gen_message_json.go30
1 files changed, 16 insertions, 14 deletions
diff --git a/whisper/whisperv6/gen_message_json.go b/whisper/whisperv6/gen_message_json.go
index 27b46752b..6218f5df6 100644
--- a/whisper/whisperv6/gen_message_json.go
+++ b/whisper/whisperv6/gen_message_json.go
@@ -10,6 +10,7 @@ import (
var _ = (*messageOverride)(nil)
+// MarshalJSON marshals type Message to a json string
func (m Message) MarshalJSON() ([]byte, error) {
type Message struct {
Sig hexutil.Bytes `json:"sig,omitempty"`
@@ -35,24 +36,25 @@ func (m Message) MarshalJSON() ([]byte, error) {
return json.Marshal(&enc)
}
+// UnmarshalJSON unmarshals type Message to a json string
func (m *Message) UnmarshalJSON(input []byte) error {
type Message struct {
- Sig hexutil.Bytes `json:"sig,omitempty"`
- TTL *uint32 `json:"ttl"`
- Timestamp *uint32 `json:"timestamp"`
- Topic *TopicType `json:"topic"`
- Payload hexutil.Bytes `json:"payload"`
- Padding hexutil.Bytes `json:"padding"`
- PoW *float64 `json:"pow"`
- Hash hexutil.Bytes `json:"hash"`
- Dst hexutil.Bytes `json:"recipientPublicKey,omitempty"`
+ Sig *hexutil.Bytes `json:"sig,omitempty"`
+ TTL *uint32 `json:"ttl"`
+ Timestamp *uint32 `json:"timestamp"`
+ Topic *TopicType `json:"topic"`
+ Payload *hexutil.Bytes `json:"payload"`
+ Padding *hexutil.Bytes `json:"padding"`
+ PoW *float64 `json:"pow"`
+ Hash *hexutil.Bytes `json:"hash"`
+ Dst *hexutil.Bytes `json:"recipientPublicKey,omitempty"`
}
var dec Message
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
if dec.Sig != nil {
- m.Sig = dec.Sig
+ m.Sig = *dec.Sig
}
if dec.TTL != nil {
m.TTL = *dec.TTL
@@ -64,19 +66,19 @@ func (m *Message) UnmarshalJSON(input []byte) error {
m.Topic = *dec.Topic
}
if dec.Payload != nil {
- m.Payload = dec.Payload
+ m.Payload = *dec.Payload
}
if dec.Padding != nil {
- m.Padding = dec.Padding
+ m.Padding = *dec.Padding
}
if dec.PoW != nil {
m.PoW = *dec.PoW
}
if dec.Hash != nil {
- m.Hash = dec.Hash
+ m.Hash = *dec.Hash
}
if dec.Dst != nil {
- m.Dst = dec.Dst
+ m.Dst = *dec.Dst
}
return nil
}