github.com/phillinzzz/newBsc@v1.1.6/eth/catalyst/gen_blockparams.go (about) 1 // Code generated by github.com/fjl/gencodec. DO NOT EDIT. 2 3 package catalyst 4 5 import ( 6 "encoding/json" 7 "errors" 8 9 "github.com/phillinzzz/newBsc/common" 10 "github.com/phillinzzz/newBsc/common/hexutil" 11 ) 12 13 var _ = (*assembleBlockParamsMarshaling)(nil) 14 15 // MarshalJSON marshals as JSON. 16 func (a assembleBlockParams) MarshalJSON() ([]byte, error) { 17 type assembleBlockParams struct { 18 ParentHash common.Hash `json:"parentHash" gencodec:"required"` 19 Timestamp hexutil.Uint64 `json:"timestamp" gencodec:"required"` 20 } 21 var enc assembleBlockParams 22 enc.ParentHash = a.ParentHash 23 enc.Timestamp = hexutil.Uint64(a.Timestamp) 24 return json.Marshal(&enc) 25 } 26 27 // UnmarshalJSON unmarshals from JSON. 28 func (a *assembleBlockParams) UnmarshalJSON(input []byte) error { 29 type assembleBlockParams struct { 30 ParentHash *common.Hash `json:"parentHash" gencodec:"required"` 31 Timestamp *hexutil.Uint64 `json:"timestamp" gencodec:"required"` 32 } 33 var dec assembleBlockParams 34 if err := json.Unmarshal(input, &dec); err != nil { 35 return err 36 } 37 if dec.ParentHash == nil { 38 return errors.New("missing required field 'parentHash' for assembleBlockParams") 39 } 40 a.ParentHash = *dec.ParentHash 41 if dec.Timestamp == nil { 42 return errors.New("missing required field 'timestamp' for assembleBlockParams") 43 } 44 a.Timestamp = uint64(*dec.Timestamp) 45 return nil 46 }