mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 23:56:43 +00:00
* feat(core): decode basefee params from `block.extraData` * feat: add `CalcBaseFeeOntake`
74 lines
2.5 KiB
Go
74 lines
2.5 KiB
Go
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
|
|
|
|
package engine
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
|
)
|
|
|
|
var _ = (*blockMetadataMarshaling)(nil)
|
|
|
|
// MarshalJSON marshals as JSON.
|
|
func (b BlockMetadata) MarshalJSON() ([]byte, error) {
|
|
type BlockMetadata struct {
|
|
Beneficiary common.Address `json:"beneficiary" gencodec:"required"`
|
|
GasLimit uint64 `json:"gasLimit" gencodec:"required"`
|
|
Timestamp hexutil.Uint64 `json:"timestamp" gencodec:"required"`
|
|
MixHash common.Hash `json:"mixHash" gencodec:"required"`
|
|
TxList hexutil.Bytes `json:"txList" gencodec:"required"`
|
|
ExtraData []byte `json:"extraData" gencodec:"required"`
|
|
}
|
|
var enc BlockMetadata
|
|
enc.Beneficiary = b.Beneficiary
|
|
enc.GasLimit = b.GasLimit
|
|
enc.Timestamp = hexutil.Uint64(b.Timestamp)
|
|
enc.MixHash = b.MixHash
|
|
enc.TxList = b.TxList
|
|
enc.ExtraData = b.ExtraData
|
|
return json.Marshal(&enc)
|
|
}
|
|
|
|
// UnmarshalJSON unmarshals from JSON.
|
|
func (b *BlockMetadata) UnmarshalJSON(input []byte) error {
|
|
type BlockMetadata struct {
|
|
Beneficiary *common.Address `json:"beneficiary" gencodec:"required"`
|
|
GasLimit *uint64 `json:"gasLimit" gencodec:"required"`
|
|
Timestamp *hexutil.Uint64 `json:"timestamp" gencodec:"required"`
|
|
MixHash *common.Hash `json:"mixHash" gencodec:"required"`
|
|
TxList *hexutil.Bytes `json:"txList" gencodec:"required"`
|
|
ExtraData []byte `json:"extraData" gencodec:"required"`
|
|
}
|
|
var dec BlockMetadata
|
|
if err := json.Unmarshal(input, &dec); err != nil {
|
|
return err
|
|
}
|
|
if dec.Beneficiary == nil {
|
|
return errors.New("missing required field 'beneficiary' for BlockMetadata")
|
|
}
|
|
b.Beneficiary = *dec.Beneficiary
|
|
if dec.GasLimit == nil {
|
|
return errors.New("missing required field 'gasLimit' for BlockMetadata")
|
|
}
|
|
b.GasLimit = *dec.GasLimit
|
|
if dec.Timestamp == nil {
|
|
return errors.New("missing required field 'timestamp' for BlockMetadata")
|
|
}
|
|
b.Timestamp = uint64(*dec.Timestamp)
|
|
if dec.MixHash == nil {
|
|
return errors.New("missing required field 'mixHash' for BlockMetadata")
|
|
}
|
|
b.MixHash = *dec.MixHash
|
|
if dec.TxList == nil {
|
|
return errors.New("missing required field 'txList' for BlockMetadata")
|
|
}
|
|
b.TxList = *dec.TxList
|
|
if dec.ExtraData == nil {
|
|
return errors.New("missing required field 'extraData' for BlockMetadata")
|
|
}
|
|
b.ExtraData = dec.ExtraData
|
|
return nil
|
|
}
|