github.com/anthdm/go-ethereum@v1.8.4-0.20180412101906-60516c83b011/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 var _ = (*criteriaOverride)(nil) 12 13 func (c Criteria) MarshalJSON() ([]byte, error) { 14 type Criteria struct { 15 SymKeyID string `json:"symKeyID"` 16 PrivateKeyID string `json:"privateKeyID"` 17 Sig hexutil.Bytes `json:"sig"` 18 MinPow float64 `json:"minPow"` 19 Topics []TopicType `json:"topics"` 20 AllowP2P bool `json:"allowP2P"` 21 } 22 var enc Criteria 23 enc.SymKeyID = c.SymKeyID 24 enc.PrivateKeyID = c.PrivateKeyID 25 enc.Sig = c.Sig 26 enc.MinPow = c.MinPow 27 enc.Topics = c.Topics 28 enc.AllowP2P = c.AllowP2P 29 return json.Marshal(&enc) 30 } 31 32 func (c *Criteria) UnmarshalJSON(input []byte) error { 33 type Criteria struct { 34 SymKeyID *string `json:"symKeyID"` 35 PrivateKeyID *string `json:"privateKeyID"` 36 Sig *hexutil.Bytes `json:"sig"` 37 MinPow *float64 `json:"minPow"` 38 Topics []TopicType `json:"topics"` 39 AllowP2P *bool `json:"allowP2P"` 40 } 41 var dec Criteria 42 if err := json.Unmarshal(input, &dec); err != nil { 43 return err 44 } 45 if dec.SymKeyID != nil { 46 c.SymKeyID = *dec.SymKeyID 47 } 48 if dec.PrivateKeyID != nil { 49 c.PrivateKeyID = *dec.PrivateKeyID 50 } 51 if dec.Sig != nil { 52 c.Sig = *dec.Sig 53 } 54 if dec.MinPow != nil { 55 c.MinPow = *dec.MinPow 56 } 57 if dec.Topics != nil { 58 c.Topics = dec.Topics 59 } 60 if dec.AllowP2P != nil { 61 c.AllowP2P = *dec.AllowP2P 62 } 63 return nil 64 }