gen_btheader.go 3.3 KB

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