aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv6/gen_message_json.go
diff options
context:
space:
mode:
authorgluk256 <gluk256@users.noreply.github.com>2017-11-04 04:29:49 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-11-04 04:29:49 +0800
commit9f7cd7568275e2db45a3d90429f7c92bf7dfbf19 (patch)
treee3fd637e6cd7b9968b4bedb030959167e299c136 /whisper/whisperv6/gen_message_json.go
parent0131bd6ff9b1850fdd307715c62174af4f05d2c7 (diff)
downloadgo-tangerine-9f7cd7568275e2db45a3d90429f7c92bf7dfbf19.tar
go-tangerine-9f7cd7568275e2db45a3d90429f7c92bf7dfbf19.tar.gz
go-tangerine-9f7cd7568275e2db45a3d90429f7c92bf7dfbf19.tar.bz2
go-tangerine-9f7cd7568275e2db45a3d90429f7c92bf7dfbf19.tar.lz
go-tangerine-9f7cd7568275e2db45a3d90429f7c92bf7dfbf19.tar.xz
go-tangerine-9f7cd7568275e2db45a3d90429f7c92bf7dfbf19.tar.zst
go-tangerine-9f7cd7568275e2db45a3d90429f7c92bf7dfbf19.zip
whisper/whisperv6: initial commit (clone of v5) (#15324)
Diffstat (limited to 'whisper/whisperv6/gen_message_json.go')
-rw-r--r--whisper/whisperv6/gen_message_json.go82
1 files changed, 82 insertions, 0 deletions
diff --git a/whisper/whisperv6/gen_message_json.go b/whisper/whisperv6/gen_message_json.go
new file mode 100644
index 000000000..27b46752b
--- /dev/null
+++ b/whisper/whisperv6/gen_message_json.go
@@ -0,0 +1,82 @@
+// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
+
+package whisperv6
+
+import (
+ "encoding/json"
+
+ "github.com/ethereum/go-ethereum/common/hexutil"
+)
+
+var _ = (*messageOverride)(nil)
+
+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
+}