gen_difficultytest.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Code generated by github.com/fjl/gencodec. DO NOT EDIT.
  2. package tests
  3. import (
  4. "encoding/json"
  5. "math/big"
  6. "github.com/ethereum/go-ethereum/common"
  7. "github.com/ethereum/go-ethereum/common/math"
  8. )
  9. var _ = (*difficultyTestMarshaling)(nil)
  10. func (d DifficultyTest) MarshalJSON() ([]byte, error) {
  11. type DifficultyTest struct {
  12. ParentTimestamp *math.HexOrDecimal256 `json:"parentTimestamp"`
  13. ParentDifficulty *math.HexOrDecimal256 `json:"parentDifficulty"`
  14. UncleHash common.Hash `json:"parentUncles"`
  15. CurrentTimestamp *math.HexOrDecimal256 `json:"currentTimestamp"`
  16. CurrentBlockNumber math.HexOrDecimal64 `json:"currentBlockNumber"`
  17. CurrentDifficulty *math.HexOrDecimal256 `json:"currentDifficulty"`
  18. }
  19. var enc DifficultyTest
  20. enc.ParentTimestamp = (*math.HexOrDecimal256)(d.ParentTimestamp)
  21. enc.ParentDifficulty = (*math.HexOrDecimal256)(d.ParentDifficulty)
  22. enc.UncleHash = d.UncleHash
  23. enc.CurrentTimestamp = (*math.HexOrDecimal256)(d.CurrentTimestamp)
  24. enc.CurrentBlockNumber = math.HexOrDecimal64(d.CurrentBlockNumber)
  25. enc.CurrentDifficulty = (*math.HexOrDecimal256)(d.CurrentDifficulty)
  26. return json.Marshal(&enc)
  27. }
  28. func (d *DifficultyTest) UnmarshalJSON(input []byte) error {
  29. type DifficultyTest struct {
  30. ParentTimestamp *math.HexOrDecimal256 `json:"parentTimestamp"`
  31. ParentDifficulty *math.HexOrDecimal256 `json:"parentDifficulty"`
  32. UncleHash *common.Hash `json:"parentUncles"`
  33. CurrentTimestamp *math.HexOrDecimal256 `json:"currentTimestamp"`
  34. CurrentBlockNumber *math.HexOrDecimal64 `json:"currentBlockNumber"`
  35. CurrentDifficulty *math.HexOrDecimal256 `json:"currentDifficulty"`
  36. }
  37. var dec DifficultyTest
  38. if err := json.Unmarshal(input, &dec); err != nil {
  39. return err
  40. }
  41. if dec.ParentTimestamp != nil {
  42. d.ParentTimestamp = (*big.Int)(dec.ParentTimestamp)
  43. }
  44. if dec.ParentDifficulty != nil {
  45. d.ParentDifficulty = (*big.Int)(dec.ParentDifficulty)
  46. }
  47. if dec.UncleHash != nil {
  48. d.UncleHash = *dec.UncleHash
  49. }
  50. if dec.CurrentTimestamp != nil {
  51. d.CurrentTimestamp = (*big.Int)(dec.CurrentTimestamp)
  52. }
  53. if dec.CurrentBlockNumber != nil {
  54. d.CurrentBlockNumber = uint64(*dec.CurrentBlockNumber)
  55. }
  56. if dec.CurrentDifficulty != nil {
  57. d.CurrentDifficulty = (*big.Int)(dec.CurrentDifficulty)
  58. }
  59. return nil
  60. }