gen_btheader.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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/hexutil"
  8. "github.com/ethereum/go-ethereum/common/math"
  9. "github.com/ethereum/go-ethereum/core/types"
  10. )
  11. var _ = (*btHeaderMarshaling)(nil)
  12. func (b btHeader) MarshalJSON() ([]byte, error) {
  13. type btHeader struct {
  14. Bloom types.Bloom
  15. Coinbase common.Address
  16. MixHash common.Hash
  17. Nonce types.BlockNonce
  18. Number *math.HexOrDecimal256
  19. Hash common.Hash
  20. ParentHash common.Hash
  21. ReceiptTrie common.Hash
  22. StateRoot common.Hash
  23. TransactionsTrie common.Hash
  24. UncleHash common.Hash
  25. ExtraData hexutil.Bytes
  26. Difficulty *math.HexOrDecimal256
  27. GasLimit math.HexOrDecimal64
  28. GasUsed math.HexOrDecimal64
  29. Timestamp *math.HexOrDecimal256
  30. }
  31. var enc btHeader
  32. enc.Bloom = b.Bloom
  33. enc.Coinbase = b.Coinbase
  34. enc.MixHash = b.MixHash
  35. enc.Nonce = b.Nonce
  36. enc.Number = (*math.HexOrDecimal256)(b.Number)
  37. enc.Hash = b.Hash
  38. enc.ParentHash = b.ParentHash
  39. enc.ReceiptTrie = b.ReceiptTrie
  40. enc.StateRoot = b.StateRoot
  41. enc.TransactionsTrie = b.TransactionsTrie
  42. enc.UncleHash = b.UncleHash
  43. enc.ExtraData = b.ExtraData
  44. enc.Difficulty = (*math.HexOrDecimal256)(b.Difficulty)
  45. enc.GasLimit = math.HexOrDecimal64(b.GasLimit)
  46. enc.GasUsed = math.HexOrDecimal64(b.GasUsed)
  47. enc.Timestamp = (*math.HexOrDecimal256)(b.Timestamp)
  48. return json.Marshal(&enc)
  49. }
  50. func (b *btHeader) UnmarshalJSON(input []byte) error {
  51. type btHeader struct {
  52. Bloom *types.Bloom
  53. Coinbase *common.Address
  54. MixHash *common.Hash
  55. Nonce *types.BlockNonce
  56. Number *math.HexOrDecimal256
  57. Hash *common.Hash
  58. ParentHash *common.Hash
  59. ReceiptTrie *common.Hash
  60. StateRoot *common.Hash
  61. TransactionsTrie *common.Hash
  62. UncleHash *common.Hash
  63. ExtraData *hexutil.Bytes
  64. Difficulty *math.HexOrDecimal256
  65. GasLimit *math.HexOrDecimal64
  66. GasUsed *math.HexOrDecimal64
  67. Timestamp *math.HexOrDecimal256
  68. }
  69. var dec btHeader
  70. if err := json.Unmarshal(input, &dec); err != nil {
  71. return err
  72. }
  73. if dec.Bloom != nil {
  74. b.Bloom = *dec.Bloom
  75. }
  76. if dec.Coinbase != nil {
  77. b.Coinbase = *dec.Coinbase
  78. }
  79. if dec.MixHash != nil {
  80. b.MixHash = *dec.MixHash
  81. }
  82. if dec.Nonce != nil {
  83. b.Nonce = *dec.Nonce
  84. }
  85. if dec.Number != nil {
  86. b.Number = (*big.Int)(dec.Number)
  87. }
  88. if dec.Hash != nil {
  89. b.Hash = *dec.Hash
  90. }
  91. if dec.ParentHash != nil {
  92. b.ParentHash = *dec.ParentHash
  93. }
  94. if dec.ReceiptTrie != nil {
  95. b.ReceiptTrie = *dec.ReceiptTrie
  96. }
  97. if dec.StateRoot != nil {
  98. b.StateRoot = *dec.StateRoot
  99. }
  100. if dec.TransactionsTrie != nil {
  101. b.TransactionsTrie = *dec.TransactionsTrie
  102. }
  103. if dec.UncleHash != nil {
  104. b.UncleHash = *dec.UncleHash
  105. }
  106. if dec.ExtraData != nil {
  107. b.ExtraData = *dec.ExtraData
  108. }
  109. if dec.Difficulty != nil {
  110. b.Difficulty = (*big.Int)(dec.Difficulty)
  111. }
  112. if dec.GasLimit != nil {
  113. b.GasLimit = uint64(*dec.GasLimit)
  114. }
  115. if dec.GasUsed != nil {
  116. b.GasUsed = uint64(*dec.GasUsed)
  117. }
  118. if dec.Timestamp != nil {
  119. b.Timestamp = (*big.Int)(dec.Timestamp)
  120. }
  121. return nil
  122. }