gen_btheader.go 3.5 KB

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