github.com/myafeier/go-ethereum@v1.6.8-0.20170719123245-3e0dbe0eaa72/whisper/whisperv5/gen_criteria_json.go (about) 1 // Code generated by github.com/fjl/gencodec. DO NOT EDIT. 2 3 package whisperv5 4 5 import ( 6 "encoding/json" 7 8 "github.com/ethereum/go-ethereum/common/hexutil" 9 ) 10 11 func (c Criteria) MarshalJSON() ([]byte, error) { 12 type Criteria struct { 13 SymKeyID string `json:"symKeyID"` 14 PrivateKeyID string `json:"privateKeyID"` 15 Sig hexutil.Bytes `json:"sig"` 16 MinPow float64 `json:"minPow"` 17 Topics []TopicType `json:"topics"` 18 AllowP2P bool `json:"allowP2P"` 19 } 20 var enc Criteria 21 enc.SymKeyID = c.SymKeyID 22 enc.PrivateKeyID = c.PrivateKeyID 23 enc.Sig = c.Sig 24 enc.MinPow = c.MinPow 25 enc.Topics = c.Topics 26 enc.AllowP2P = c.AllowP2P 27 return json.Marshal(&enc) 28 } 29 30 func (c *Criteria) UnmarshalJSON(input []byte) error { 31 type Criteria struct { 32 SymKeyID *string `json:"symKeyID"` 33 PrivateKeyID *string `json:"privateKeyID"` 34 Sig hexutil.Bytes `json:"sig"` 35 MinPow *float64 `json:"minPow"` 36 Topics []TopicType `json:"topics"` 37 AllowP2P *bool `json:"allowP2P"` 38 } 39 var dec Criteria 40 if err := json.Unmarshal(input, &dec); err != nil { 41 return err 42 } 43 if dec.SymKeyID != nil { 44 c.SymKeyID = *dec.SymKeyID 45 } 46 if dec.PrivateKeyID != nil { 47 c.PrivateKeyID = *dec.PrivateKeyID 48 } 49 if dec.Sig != nil { 50 c.Sig = dec.Sig 51 } 52 if dec.MinPow != nil { 53 c.MinPow = *dec.MinPow 54 } 55 if dec.Topics != nil { 56 c.Topics = dec.Topics 57 } 58 if dec.AllowP2P != nil { 59 c.AllowP2P = *dec.AllowP2P 60 } 61 return nil 62 }