You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
4.3 KiB
117 lines
4.3 KiB
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
|
|
|
|
package v1
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"math/big"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
|
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
|
)
|
|
|
|
var _ = (*headerMarshaling)(nil)
|
|
|
|
func (h Header) MarshalJSON() ([]byte, error) {
|
|
// TODO: update with new fields
|
|
type Header struct {
|
|
ParentHash common.Hash `json:"parentHash" gencodec:"required"`
|
|
Coinbase common.Address `json:"miner" gencodec:"required"`
|
|
Root common.Hash `json:"stateRoot" gencodec:"required"`
|
|
TxHash common.Hash `json:"transactionsRoot" gencodec:"required"`
|
|
ReceiptHash common.Hash `json:"receiptsRoot" gencodec:"required"`
|
|
Bloom ethtypes.Bloom `json:"logsBloom" gencodec:"required"`
|
|
Number *hexutil.Big `json:"number" gencodec:"required"`
|
|
GasLimit hexutil.Uint64 `json:"gasLimit" gencodec:"required"`
|
|
GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"`
|
|
Time *hexutil.Big `json:"timestamp" gencodec:"required"`
|
|
Extra hexutil.Bytes `json:"extraData" gencodec:"required"`
|
|
MixDigest common.Hash `json:"mixHash" gencodec:"required"`
|
|
Hash common.Hash `json:"hash"`
|
|
}
|
|
var enc Header
|
|
enc.ParentHash = h.ParentHash()
|
|
enc.Coinbase = h.Coinbase()
|
|
enc.Root = h.Root()
|
|
enc.TxHash = h.TxHash()
|
|
enc.ReceiptHash = h.ReceiptHash()
|
|
enc.Bloom = h.Bloom()
|
|
enc.Number = (*hexutil.Big)(h.Number())
|
|
enc.GasLimit = hexutil.Uint64(h.GasLimit())
|
|
enc.GasUsed = hexutil.Uint64(h.GasUsed())
|
|
enc.Time = (*hexutil.Big)(h.Time())
|
|
enc.Extra = h.Extra()
|
|
enc.MixDigest = h.MixDigest()
|
|
enc.Hash = h.Hash()
|
|
return json.Marshal(&enc)
|
|
}
|
|
|
|
func (h *Header) UnmarshalJSON(input []byte) error {
|
|
// TODO: update with new fields
|
|
type Header struct {
|
|
ParentHash *common.Hash `json:"parentHash" gencodec:"required"`
|
|
Coinbase *common.Address `json:"miner" gencodec:"required"`
|
|
Root *common.Hash `json:"stateRoot" gencodec:"required"`
|
|
TxHash *common.Hash `json:"transactionsRoot" gencodec:"required"`
|
|
ReceiptHash *common.Hash `json:"receiptsRoot" gencodec:"required"`
|
|
Bloom *ethtypes.Bloom `json:"logsBloom" gencodec:"required"`
|
|
Number *hexutil.Big `json:"number" gencodec:"required"`
|
|
GasLimit *hexutil.Uint64 `json:"gasLimit" gencodec:"required"`
|
|
GasUsed *hexutil.Uint64 `json:"gasUsed" gencodec:"required"`
|
|
Time *hexutil.Big `json:"timestamp" gencodec:"required"`
|
|
Extra *hexutil.Bytes `json:"extraData" gencodec:"required"`
|
|
MixDigest *common.Hash `json:"mixHash" gencodec:"required"`
|
|
}
|
|
var dec Header
|
|
if err := json.Unmarshal(input, &dec); err != nil {
|
|
return err
|
|
}
|
|
if dec.ParentHash == nil {
|
|
return errors.New("missing required field 'parentHash' for Header")
|
|
}
|
|
h.SetParentHash(*dec.ParentHash)
|
|
if dec.Coinbase == nil {
|
|
return errors.New("missing required field 'miner' for Header")
|
|
}
|
|
h.SetCoinbase(*dec.Coinbase)
|
|
if dec.Root == nil {
|
|
return errors.New("missing required field 'stateRoot' for Header")
|
|
}
|
|
h.SetRoot(*dec.Root)
|
|
if dec.TxHash == nil {
|
|
return errors.New("missing required field 'transactionsRoot' for Header")
|
|
}
|
|
h.SetTxHash(*dec.TxHash)
|
|
if dec.ReceiptHash == nil {
|
|
return errors.New("missing required field 'receiptsRoot' for Header")
|
|
}
|
|
h.SetReceiptHash(*dec.ReceiptHash)
|
|
if dec.Bloom == nil {
|
|
return errors.New("missing required field 'logsBloom' for Header")
|
|
}
|
|
h.SetBloom(*dec.Bloom)
|
|
h.SetNumber((*big.Int)(dec.Number))
|
|
if dec.GasLimit == nil {
|
|
return errors.New("missing required field 'gasLimit' for Header")
|
|
}
|
|
h.SetGasLimit(uint64(*dec.GasLimit))
|
|
if dec.GasUsed == nil {
|
|
return errors.New("missing required field 'gasUsed' for Header")
|
|
}
|
|
h.SetGasUsed(uint64(*dec.GasUsed))
|
|
if dec.Time == nil {
|
|
return errors.New("missing required field 'timestamp' for Header")
|
|
}
|
|
h.SetTime((*big.Int)(dec.Time))
|
|
if dec.Extra == nil {
|
|
return errors.New("missing required field 'extraData' for Header")
|
|
}
|
|
h.SetExtra(*dec.Extra)
|
|
if dec.MixDigest == nil {
|
|
return errors.New("missing required field 'mixHash' for Header")
|
|
}
|
|
h.SetMixDigest(*dec.MixDigest)
|
|
return nil
|
|
}
|
|
|