github.com/phillinzzz/newBsc@v1.1.6/eth/catalyst/gen_ed.go (about)

     1  // Code generated by github.com/fjl/gencodec. DO NOT EDIT.
     2  
     3  package catalyst
     4  
     5  import (
     6  	"encoding/json"
     7  	"errors"
     8  
     9  	"github.com/phillinzzz/newBsc/common"
    10  	"github.com/phillinzzz/newBsc/common/hexutil"
    11  )
    12  
    13  var _ = (*executableDataMarshaling)(nil)
    14  
    15  // MarshalJSON marshals as JSON.
    16  func (e executableData) MarshalJSON() ([]byte, error) {
    17  	type executableData struct {
    18  		BlockHash    common.Hash     `json:"blockHash"     gencodec:"required"`
    19  		ParentHash   common.Hash     `json:"parentHash"    gencodec:"required"`
    20  		Miner        common.Address  `json:"miner"         gencodec:"required"`
    21  		StateRoot    common.Hash     `json:"stateRoot"     gencodec:"required"`
    22  		Number       hexutil.Uint64  `json:"number"        gencodec:"required"`
    23  		GasLimit     hexutil.Uint64  `json:"gasLimit"      gencodec:"required"`
    24  		GasUsed      hexutil.Uint64  `json:"gasUsed"       gencodec:"required"`
    25  		Timestamp    hexutil.Uint64  `json:"timestamp"     gencodec:"required"`
    26  		ReceiptRoot  common.Hash     `json:"receiptsRoot"  gencodec:"required"`
    27  		LogsBloom    hexutil.Bytes   `json:"logsBloom"     gencodec:"required"`
    28  		Transactions []hexutil.Bytes `json:"transactions"  gencodec:"required"`
    29  	}
    30  	var enc executableData
    31  	enc.BlockHash = e.BlockHash
    32  	enc.ParentHash = e.ParentHash
    33  	enc.Miner = e.Miner
    34  	enc.StateRoot = e.StateRoot
    35  	enc.Number = hexutil.Uint64(e.Number)
    36  	enc.GasLimit = hexutil.Uint64(e.GasLimit)
    37  	enc.GasUsed = hexutil.Uint64(e.GasUsed)
    38  	enc.Timestamp = hexutil.Uint64(e.Timestamp)
    39  	enc.ReceiptRoot = e.ReceiptRoot
    40  	enc.LogsBloom = e.LogsBloom
    41  	if e.Transactions != nil {
    42  		enc.Transactions = make([]hexutil.Bytes, len(e.Transactions))
    43  		for k, v := range e.Transactions {
    44  			enc.Transactions[k] = v
    45  		}
    46  	}
    47  	return json.Marshal(&enc)
    48  }
    49  
    50  // UnmarshalJSON unmarshals from JSON.
    51  func (e *executableData) UnmarshalJSON(input []byte) error {
    52  	type executableData struct {
    53  		BlockHash    *common.Hash    `json:"blockHash"     gencodec:"required"`
    54  		ParentHash   *common.Hash    `json:"parentHash"    gencodec:"required"`
    55  		Miner        *common.Address `json:"miner"         gencodec:"required"`
    56  		StateRoot    *common.Hash    `json:"stateRoot"     gencodec:"required"`
    57  		Number       *hexutil.Uint64 `json:"number"        gencodec:"required"`
    58  		GasLimit     *hexutil.Uint64 `json:"gasLimit"      gencodec:"required"`
    59  		GasUsed      *hexutil.Uint64 `json:"gasUsed"       gencodec:"required"`
    60  		Timestamp    *hexutil.Uint64 `json:"timestamp"     gencodec:"required"`
    61  		ReceiptRoot  *common.Hash    `json:"receiptsRoot"  gencodec:"required"`
    62  		LogsBloom    *hexutil.Bytes  `json:"logsBloom"     gencodec:"required"`
    63  		Transactions []hexutil.Bytes `json:"transactions"  gencodec:"required"`
    64  	}
    65  	var dec executableData
    66  	if err := json.Unmarshal(input, &dec); err != nil {
    67  		return err
    68  	}
    69  	if dec.BlockHash == nil {
    70  		return errors.New("missing required field 'blockHash' for executableData")
    71  	}
    72  	e.BlockHash = *dec.BlockHash
    73  	if dec.ParentHash == nil {
    74  		return errors.New("missing required field 'parentHash' for executableData")
    75  	}
    76  	e.ParentHash = *dec.ParentHash
    77  	if dec.Miner == nil {
    78  		return errors.New("missing required field 'miner' for executableData")
    79  	}
    80  	e.Miner = *dec.Miner
    81  	if dec.StateRoot == nil {
    82  		return errors.New("missing required field 'stateRoot' for executableData")
    83  	}
    84  	e.StateRoot = *dec.StateRoot
    85  	if dec.Number == nil {
    86  		return errors.New("missing required field 'number' for executableData")
    87  	}
    88  	e.Number = uint64(*dec.Number)
    89  	if dec.GasLimit == nil {
    90  		return errors.New("missing required field 'gasLimit' for executableData")
    91  	}
    92  	e.GasLimit = uint64(*dec.GasLimit)
    93  	if dec.GasUsed == nil {
    94  		return errors.New("missing required field 'gasUsed' for executableData")
    95  	}
    96  	e.GasUsed = uint64(*dec.GasUsed)
    97  	if dec.Timestamp == nil {
    98  		return errors.New("missing required field 'timestamp' for executableData")
    99  	}
   100  	e.Timestamp = uint64(*dec.Timestamp)
   101  	if dec.ReceiptRoot == nil {
   102  		return errors.New("missing required field 'receiptsRoot' for executableData")
   103  	}
   104  	e.ReceiptRoot = *dec.ReceiptRoot
   105  	if dec.LogsBloom == nil {
   106  		return errors.New("missing required field 'logsBloom' for executableData")
   107  	}
   108  	e.LogsBloom = *dec.LogsBloom
   109  	if dec.Transactions == nil {
   110  		return errors.New("missing required field 'transactions' for executableData")
   111  	}
   112  	e.Transactions = make([][]byte, len(dec.Transactions))
   113  	for k, v := range dec.Transactions {
   114  		e.Transactions[k] = v
   115  	}
   116  	return nil
   117  }