github.com/luckypickle/go-ethereum-vet@v1.14.2/whisper/whisperv5/gen_message_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/luckypickle/go-ethereum-vet/common/hexutil"
     9  )
    10  
    11  var _ = (*messageOverride)(nil)
    12  
    13  func (m Message) MarshalJSON() ([]byte, error) {
    14  	type Message struct {
    15  		Sig       hexutil.Bytes `json:"sig,omitempty"`
    16  		TTL       uint32        `json:"ttl"`
    17  		Timestamp uint32        `json:"timestamp"`
    18  		Topic     TopicType     `json:"topic"`
    19  		Payload   hexutil.Bytes `json:"payload"`
    20  		Padding   hexutil.Bytes `json:"padding"`
    21  		PoW       float64       `json:"pow"`
    22  		Hash      hexutil.Bytes `json:"hash"`
    23  		Dst       hexutil.Bytes `json:"recipientPublicKey,omitempty"`
    24  	}
    25  	var enc Message
    26  	enc.Sig = m.Sig
    27  	enc.TTL = m.TTL
    28  	enc.Timestamp = m.Timestamp
    29  	enc.Topic = m.Topic
    30  	enc.Payload = m.Payload
    31  	enc.Padding = m.Padding
    32  	enc.PoW = m.PoW
    33  	enc.Hash = m.Hash
    34  	enc.Dst = m.Dst
    35  	return json.Marshal(&enc)
    36  }
    37  
    38  func (m *Message) UnmarshalJSON(input []byte) error {
    39  	type Message struct {
    40  		Sig       *hexutil.Bytes `json:"sig,omitempty"`
    41  		TTL       *uint32        `json:"ttl"`
    42  		Timestamp *uint32        `json:"timestamp"`
    43  		Topic     *TopicType     `json:"topic"`
    44  		Payload   *hexutil.Bytes `json:"payload"`
    45  		Padding   *hexutil.Bytes `json:"padding"`
    46  		PoW       *float64       `json:"pow"`
    47  		Hash      *hexutil.Bytes `json:"hash"`
    48  		Dst       *hexutil.Bytes `json:"recipientPublicKey,omitempty"`
    49  	}
    50  	var dec Message
    51  	if err := json.Unmarshal(input, &dec); err != nil {
    52  		return err
    53  	}
    54  	if dec.Sig != nil {
    55  		m.Sig = *dec.Sig
    56  	}
    57  	if dec.TTL != nil {
    58  		m.TTL = *dec.TTL
    59  	}
    60  	if dec.Timestamp != nil {
    61  		m.Timestamp = *dec.Timestamp
    62  	}
    63  	if dec.Topic != nil {
    64  		m.Topic = *dec.Topic
    65  	}
    66  	if dec.Payload != nil {
    67  		m.Payload = *dec.Payload
    68  	}
    69  	if dec.Padding != nil {
    70  		m.Padding = *dec.Padding
    71  	}
    72  	if dec.PoW != nil {
    73  		m.PoW = *dec.PoW
    74  	}
    75  	if dec.Hash != nil {
    76  		m.Hash = *dec.Hash
    77  	}
    78  	if dec.Dst != nil {
    79  		m.Dst = *dec.Dst
    80  	}
    81  	return nil
    82  }