github.com/klaytn/klaytn@v1.12.1/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/klaytn/klaytn/blockchain/types"
    10  	"github.com/klaytn/klaytn/common"
    11  	"github.com/klaytn/klaytn/common/hexutil"
    12  	"github.com/klaytn/klaytn/common/math"
    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  		Number           *math.HexOrDecimal256
    22  		Hash             common.Hash
    23  		ParentHash       common.Hash
    24  		ReceiptTrie      common.Hash
    25  		StateRoot        common.Hash
    26  		TransactionsTrie common.Hash
    27  		ExtraData        hexutil.Bytes
    28  		BlockScore       *math.HexOrDecimal256
    29  		GasUsed          math.HexOrDecimal64
    30  		Timestamp        *math.HexOrDecimal256
    31  	}
    32  	var enc btHeader
    33  	enc.Bloom = b.Bloom
    34  	enc.Number = (*math.HexOrDecimal256)(b.Number)
    35  	enc.Hash = b.Hash
    36  	enc.ParentHash = b.ParentHash
    37  	enc.ReceiptTrie = b.ReceiptTrie
    38  	enc.StateRoot = b.StateRoot
    39  	enc.TransactionsTrie = b.TransactionsTrie
    40  	enc.ExtraData = b.ExtraData
    41  	enc.BlockScore = (*math.HexOrDecimal256)(b.BlockScore)
    42  	enc.GasUsed = math.HexOrDecimal64(b.GasUsed)
    43  	enc.Timestamp = (*math.HexOrDecimal256)(b.Timestamp)
    44  	return json.Marshal(&enc)
    45  }
    46  
    47  // UnmarshalJSON unmarshals from JSON.
    48  func (b *btHeader) UnmarshalJSON(input []byte) error {
    49  	type btHeader struct {
    50  		Bloom            *types.Bloom
    51  		Number           *math.HexOrDecimal256
    52  		Hash             *common.Hash
    53  		ParentHash       *common.Hash
    54  		ReceiptTrie      *common.Hash
    55  		StateRoot        *common.Hash
    56  		TransactionsTrie *common.Hash
    57  		ExtraData        *hexutil.Bytes
    58  		BlockScore       *math.HexOrDecimal256
    59  		GasUsed          *math.HexOrDecimal64
    60  		Timestamp        *math.HexOrDecimal256
    61  	}
    62  	var dec btHeader
    63  	if err := json.Unmarshal(input, &dec); err != nil {
    64  		return err
    65  	}
    66  	if dec.Bloom != nil {
    67  		b.Bloom = *dec.Bloom
    68  	}
    69  	if dec.Number != nil {
    70  		b.Number = (*big.Int)(dec.Number)
    71  	}
    72  	if dec.Hash != nil {
    73  		b.Hash = *dec.Hash
    74  	}
    75  	if dec.ParentHash != nil {
    76  		b.ParentHash = *dec.ParentHash
    77  	}
    78  	if dec.ReceiptTrie != nil {
    79  		b.ReceiptTrie = *dec.ReceiptTrie
    80  	}
    81  	if dec.StateRoot != nil {
    82  		b.StateRoot = *dec.StateRoot
    83  	}
    84  	if dec.TransactionsTrie != nil {
    85  		b.TransactionsTrie = *dec.TransactionsTrie
    86  	}
    87  	if dec.ExtraData != nil {
    88  		b.ExtraData = *dec.ExtraData
    89  	}
    90  	if dec.BlockScore != nil {
    91  		b.BlockScore = (*big.Int)(dec.BlockScore)
    92  	}
    93  	if dec.GasUsed != nil {
    94  		b.GasUsed = uint64(*dec.GasUsed)
    95  	}
    96  	if dec.Timestamp != nil {
    97  		b.Timestamp = (*big.Int)(dec.Timestamp)
    98  	}
    99  	return nil
   100  }