diff options
author | Bas van Kervel <basvankervel@gmail.com> | 2017-06-13 17:49:07 +0800 |
---|---|---|
committer | Bas van Kervel <basvankervel@gmail.com> | 2017-06-15 17:53:15 +0800 |
commit | b58a5016738b92db19e08ec87ef34ce3250fae6b (patch) | |
tree | fa9485b3f711204b14edae5dcbc812e624490c68 /whisper/whisperv5/gen_criteria_json.go | |
parent | 80f7c6c2996ad47f70a5070c400b1fd87a20c59c (diff) | |
download | dexon-b58a5016738b92db19e08ec87ef34ce3250fae6b.tar.gz dexon-b58a5016738b92db19e08ec87ef34ce3250fae6b.tar.zst dexon-b58a5016738b92db19e08ec87ef34ce3250fae6b.zip |
whisperv5: integrate whisper and add whisper RPC simulator
Diffstat (limited to 'whisper/whisperv5/gen_criteria_json.go')
-rw-r--r-- | whisper/whisperv5/gen_criteria_json.go | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/whisper/whisperv5/gen_criteria_json.go b/whisper/whisperv5/gen_criteria_json.go new file mode 100644 index 000000000..8d3e9ee24 --- /dev/null +++ b/whisper/whisperv5/gen_criteria_json.go @@ -0,0 +1,62 @@ +// Code generated by github.com/fjl/gencodec. DO NOT EDIT. + +package whisperv5 + +import ( + "encoding/json" + + "github.com/ethereum/go-ethereum/common/hexutil" +) + +func (c Criteria) MarshalJSON() ([]byte, error) { + type Criteria struct { + SymKeyID string `json:"symKeyID"` + PrivateKeyID string `json:"privateKeyID"` + Sig hexutil.Bytes `json:"sig"` + MinPow float64 `json:"minPow"` + Topics []TopicType `json:"topics"` + AllowP2P bool `json:"allowP2P"` + } + var enc Criteria + enc.SymKeyID = c.SymKeyID + enc.PrivateKeyID = c.PrivateKeyID + enc.Sig = c.Sig + enc.MinPow = c.MinPow + enc.Topics = c.Topics + enc.AllowP2P = c.AllowP2P + return json.Marshal(&enc) +} + +func (c *Criteria) UnmarshalJSON(input []byte) error { + type Criteria struct { + SymKeyID *string `json:"symKeyID"` + PrivateKeyID *string `json:"privateKeyID"` + Sig hexutil.Bytes `json:"sig"` + MinPow *float64 `json:"minPow"` + Topics []TopicType `json:"topics"` + AllowP2P *bool `json:"allowP2P"` + } + var dec Criteria + if err := json.Unmarshal(input, &dec); err != nil { + return err + } + if dec.SymKeyID != nil { + c.SymKeyID = *dec.SymKeyID + } + if dec.PrivateKeyID != nil { + c.PrivateKeyID = *dec.PrivateKeyID + } + if dec.Sig != nil { + c.Sig = dec.Sig + } + if dec.MinPow != nil { + c.MinPow = *dec.MinPow + } + if dec.Topics != nil { + c.Topics = dec.Topics + } + if dec.AllowP2P != nil { + c.AllowP2P = *dec.AllowP2P + } + return nil +} |