|
|
|
@ -39,16 +39,16 @@ func (n NewMessage) MarshalJSON() ([]byte, error) { |
|
|
|
|
|
|
|
|
|
func (n *NewMessage) UnmarshalJSON(input []byte) error { |
|
|
|
|
type NewMessage struct { |
|
|
|
|
SymKeyID *string `json:"symKeyID"` |
|
|
|
|
PublicKey hexutil.Bytes `json:"pubKey"` |
|
|
|
|
Sig *string `json:"sig"` |
|
|
|
|
TTL *uint32 `json:"ttl"` |
|
|
|
|
Topic *TopicType `json:"topic"` |
|
|
|
|
Payload hexutil.Bytes `json:"payload"` |
|
|
|
|
Padding hexutil.Bytes `json:"padding"` |
|
|
|
|
PowTime *uint32 `json:"powTime"` |
|
|
|
|
PowTarget *float64 `json:"powTarget"` |
|
|
|
|
TargetPeer *string `json:"targetPeer"` |
|
|
|
|
SymKeyID *string `json:"symKeyID"` |
|
|
|
|
PublicKey *hexutil.Bytes `json:"pubKey"` |
|
|
|
|
Sig *string `json:"sig"` |
|
|
|
|
TTL *uint32 `json:"ttl"` |
|
|
|
|
Topic *TopicType `json:"topic"` |
|
|
|
|
Payload *hexutil.Bytes `json:"payload"` |
|
|
|
|
Padding *hexutil.Bytes `json:"padding"` |
|
|
|
|
PowTime *uint32 `json:"powTime"` |
|
|
|
|
PowTarget *float64 `json:"powTarget"` |
|
|
|
|
TargetPeer *string `json:"targetPeer"` |
|
|
|
|
} |
|
|
|
|
var dec NewMessage |
|
|
|
|
if err := json.Unmarshal(input, &dec); err != nil { |
|
|
|
@ -58,7 +58,7 @@ func (n *NewMessage) UnmarshalJSON(input []byte) error { |
|
|
|
|
n.SymKeyID = *dec.SymKeyID |
|
|
|
|
} |
|
|
|
|
if dec.PublicKey != nil { |
|
|
|
|
n.PublicKey = dec.PublicKey |
|
|
|
|
n.PublicKey = *dec.PublicKey |
|
|
|
|
} |
|
|
|
|
if dec.Sig != nil { |
|
|
|
|
n.Sig = *dec.Sig |
|
|
|
@ -70,10 +70,10 @@ func (n *NewMessage) UnmarshalJSON(input []byte) error { |
|
|
|
|
n.Topic = *dec.Topic |
|
|
|
|
} |
|
|
|
|
if dec.Payload != nil { |
|
|
|
|
n.Payload = dec.Payload |
|
|
|
|
n.Payload = *dec.Payload |
|
|
|
|
} |
|
|
|
|
if dec.Padding != nil { |
|
|
|
|
n.Padding = dec.Padding |
|
|
|
|
n.Padding = *dec.Padding |
|
|
|
|
} |
|
|
|
|
if dec.PowTime != nil { |
|
|
|
|
n.PowTime = *dec.PowTime |
|
|
|
|