gen_blockparams.go 1.8 KB

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