aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv5/gen_criteria_json.go
blob: 1c0e389ad9bbf78d269c2d0d0529bb882333e4fa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.

package whisperv5

import (
    "encoding/json"

    "github.com/ethereum/go-ethereum/common/hexutil"
)

var _ = (*criteriaOverride)(nil)

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
}