aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv5/gen_message_json.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-06-26 18:44:35 +0800
committerGitHub <noreply@github.com>2017-06-26 18:44:35 +0800
commitfeb29327066d6076d1802cdc1492d43a39cec276 (patch)
tree93f3231648b0f225c0c8d44bf81304282f93b605 /whisper/whisperv5/gen_message_json.go
parentf321ed23fbaad8a13cc672f601b15f5272b4b2bb (diff)
parentea1d1825a8509b3353c535c9444861e15471942a (diff)
downloaddexon-feb29327066d6076d1802cdc1492d43a39cec276.tar
dexon-feb29327066d6076d1802cdc1492d43a39cec276.tar.gz
dexon-feb29327066d6076d1802cdc1492d43a39cec276.tar.bz2
dexon-feb29327066d6076d1802cdc1492d43a39cec276.tar.lz
dexon-feb29327066d6076d1802cdc1492d43a39cec276.tar.xz
dexon-feb29327066d6076d1802cdc1492d43a39cec276.tar.zst
dexon-feb29327066d6076d1802cdc1492d43a39cec276.zip
Merge pull request #14540 from bas-vk/whisper-api
whisperv5: integrate whisper and implement API
Diffstat (limited to 'whisper/whisperv5/gen_message_json.go')
-rw-r--r--whisper/whisperv5/gen_message_json.go80
1 files changed, 80 insertions, 0 deletions
diff --git a/whisper/whisperv5/gen_message_json.go b/whisper/whisperv5/gen_message_json.go
new file mode 100644
index 000000000..26168225c
--- /dev/null
+++ b/whisper/whisperv5/gen_message_json.go
@@ -0,0 +1,80 @@
+// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
+
+package whisperv5
+
+import (
+ "encoding/json"
+
+ "github.com/ethereum/go-ethereum/common/hexutil"
+)
+
+func (m Message) MarshalJSON() ([]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"`
+ }
+ var enc Message
+ enc.Sig = m.Sig
+ enc.TTL = m.TTL
+ enc.Timestamp = m.Timestamp
+ enc.Topic = m.Topic
+ enc.Payload = m.Payload
+ enc.Padding = m.Padding
+ enc.PoW = m.PoW
+ enc.Hash = m.Hash
+ enc.Dst = m.Dst
+ return json.Marshal(&enc)
+}
+
+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"`
+ }
+ var dec Message
+ if err := json.Unmarshal(input, &dec); err != nil {
+ return err
+ }
+ if dec.Sig != nil {
+ m.Sig = dec.Sig
+ }
+ if dec.TTL != nil {
+ m.TTL = *dec.TTL
+ }
+ if dec.Timestamp != nil {
+ m.Timestamp = *dec.Timestamp
+ }
+ if dec.Topic != nil {
+ m.Topic = *dec.Topic
+ }
+ if dec.Payload != nil {
+ m.Payload = dec.Payload
+ }
+ if dec.Padding != nil {
+ m.Padding = dec.Padding
+ }
+ if dec.PoW != nil {
+ m.PoW = *dec.PoW
+ }
+ if dec.Hash != nil {
+ m.Hash = dec.Hash
+ }
+ if dec.Dst != nil {
+ m.Dst = dec.Dst
+ }
+ return nil
+}