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