github.com/ethereum/go-ethereum@v1.14.3/tests/gen_btheader.go (about)

     1  // Code generated by github.com/fjl/gencodec. DO NOT EDIT.
     2  
     3  package tests
     4  
     5  import (
     6  	"encoding/json"
     7  	"math/big"
     8  
     9  	"github.com/ethereum/go-ethereum/common"
    10  	"github.com/ethereum/go-ethereum/common/hexutil"
    11  	"github.com/ethereum/go-ethereum/common/math"
    12  	"github.com/ethereum/go-ethereum/core/types"
    13  )
    14  
    15  var _ = (*btHeaderMarshaling)(nil)
    16  
    17  // MarshalJSON marshals as JSON.
    18  func (b btHeader) MarshalJSON() ([]byte, error) {
    19  	type btHeader struct {
    20  		Bloom                 types.Bloom
    21  		Coinbase              common.Address
    22  		MixHash               common.Hash
    23  		Nonce                 types.BlockNonce
    24  		Number                *math.HexOrDecimal256
    25  		Hash                  common.Hash
    26  		ParentHash            common.Hash
    27  		ReceiptTrie           common.Hash
    28  		StateRoot             common.Hash
    29  		TransactionsTrie      common.Hash
    30  		UncleHash             common.Hash
    31  		ExtraData             hexutil.Bytes
    32  		Difficulty            *math.HexOrDecimal256
    33  		GasLimit              math.HexOrDecimal64
    34  		GasUsed               math.HexOrDecimal64
    35  		Timestamp             math.HexOrDecimal64
    36  		BaseFeePerGas         *math.HexOrDecimal256
    37  		WithdrawalsRoot       *common.Hash
    38  		BlobGasUsed           *math.HexOrDecimal64
    39  		ExcessBlobGas         *math.HexOrDecimal64
    40  		ParentBeaconBlockRoot *common.Hash
    41  	}
    42  	var enc btHeader
    43  	enc.Bloom = b.Bloom
    44  	enc.Coinbase = b.Coinbase
    45  	enc.MixHash = b.MixHash
    46  	enc.Nonce = b.Nonce
    47  	enc.Number = (*math.HexOrDecimal256)(b.Number)
    48  	enc.Hash = b.Hash
    49  	enc.ParentHash = b.ParentHash
    50  	enc.ReceiptTrie = b.ReceiptTrie
    51  	enc.StateRoot = b.StateRoot
    52  	enc.TransactionsTrie = b.TransactionsTrie
    53  	enc.UncleHash = b.UncleHash
    54  	enc.ExtraData = b.ExtraData
    55  	enc.Difficulty = (*math.HexOrDecimal256)(b.Difficulty)
    56  	enc.GasLimit = math.HexOrDecimal64(b.GasLimit)
    57  	enc.GasUsed = math.HexOrDecimal64(b.GasUsed)
    58  	enc.Timestamp = math.HexOrDecimal64(b.Timestamp)
    59  	enc.BaseFeePerGas = (*math.HexOrDecimal256)(b.BaseFeePerGas)
    60  	enc.WithdrawalsRoot = b.WithdrawalsRoot
    61  	enc.BlobGasUsed = (*math.HexOrDecimal64)(b.BlobGasUsed)
    62  	enc.ExcessBlobGas = (*math.HexOrDecimal64)(b.ExcessBlobGas)
    63  	enc.ParentBeaconBlockRoot = b.ParentBeaconBlockRoot
    64  	return json.Marshal(&enc)
    65  }
    66  
    67  // UnmarshalJSON unmarshals from JSON.
    68  func (b *btHeader) UnmarshalJSON(input []byte) error {
    69  	type btHeader struct {
    70  		Bloom                 *types.Bloom
    71  		Coinbase              *common.Address
    72  		MixHash               *common.Hash
    73  		Nonce                 *types.BlockNonce
    74  		Number                *math.HexOrDecimal256
    75  		Hash                  *common.Hash
    76  		ParentHash            *common.Hash
    77  		ReceiptTrie           *common.Hash
    78  		StateRoot             *common.Hash
    79  		TransactionsTrie      *common.Hash
    80  		UncleHash             *common.Hash
    81  		ExtraData             *hexutil.Bytes
    82  		Difficulty            *math.HexOrDecimal256
    83  		GasLimit              *math.HexOrDecimal64
    84  		GasUsed               *math.HexOrDecimal64
    85  		Timestamp             *math.HexOrDecimal64
    86  		BaseFeePerGas         *math.HexOrDecimal256
    87  		WithdrawalsRoot       *common.Hash
    88  		BlobGasUsed           *math.HexOrDecimal64
    89  		ExcessBlobGas         *math.HexOrDecimal64
    90  		ParentBeaconBlockRoot *common.Hash
    91  	}
    92  	var dec btHeader
    93  	if err := json.Unmarshal(input, &dec); err != nil {
    94  		return err
    95  	}
    96  	if dec.Bloom != nil {
    97  		b.Bloom = *dec.Bloom
    98  	}
    99  	if dec.Coinbase != nil {
   100  		b.Coinbase = *dec.Coinbase
   101  	}
   102  	if dec.MixHash != nil {
   103  		b.MixHash = *dec.MixHash
   104  	}
   105  	if dec.Nonce != nil {
   106  		b.Nonce = *dec.Nonce
   107  	}
   108  	if dec.Number != nil {
   109  		b.Number = (*big.Int)(dec.Number)
   110  	}
   111  	if dec.Hash != nil {
   112  		b.Hash = *dec.Hash
   113  	}
   114  	if dec.ParentHash != nil {
   115  		b.ParentHash = *dec.ParentHash
   116  	}
   117  	if dec.ReceiptTrie != nil {
   118  		b.ReceiptTrie = *dec.ReceiptTrie
   119  	}
   120  	if dec.StateRoot != nil {
   121  		b.StateRoot = *dec.StateRoot
   122  	}
   123  	if dec.TransactionsTrie != nil {
   124  		b.TransactionsTrie = *dec.TransactionsTrie
   125  	}
   126  	if dec.UncleHash != nil {
   127  		b.UncleHash = *dec.UncleHash
   128  	}
   129  	if dec.ExtraData != nil {
   130  		b.ExtraData = *dec.ExtraData
   131  	}
   132  	if dec.Difficulty != nil {
   133  		b.Difficulty = (*big.Int)(dec.Difficulty)
   134  	}
   135  	if dec.GasLimit != nil {
   136  		b.GasLimit = uint64(*dec.GasLimit)
   137  	}
   138  	if dec.GasUsed != nil {
   139  		b.GasUsed = uint64(*dec.GasUsed)
   140  	}
   141  	if dec.Timestamp != nil {
   142  		b.Timestamp = uint64(*dec.Timestamp)
   143  	}
   144  	if dec.BaseFeePerGas != nil {
   145  		b.BaseFeePerGas = (*big.Int)(dec.BaseFeePerGas)
   146  	}
   147  	if dec.WithdrawalsRoot != nil {
   148  		b.WithdrawalsRoot = dec.WithdrawalsRoot
   149  	}
   150  	if dec.BlobGasUsed != nil {
   151  		b.BlobGasUsed = (*uint64)(dec.BlobGasUsed)
   152  	}
   153  	if dec.ExcessBlobGas != nil {
   154  		b.ExcessBlobGas = (*uint64)(dec.ExcessBlobGas)
   155  	}
   156  	if dec.ParentBeaconBlockRoot != nil {
   157  		b.ParentBeaconBlockRoot = dec.ParentBeaconBlockRoot
   158  	}
   159  	return nil
   160  }