go-ethereum/beacon/engine/gen_blockmetadata.go
David e6487f00ed
feat(core): introduce BasefeeSharingPctg in BlockMetadata (#287)
* feat(core): introduce `BasefeeSharingPctg` in `BlockMetadata`

* feat: update message

* feat: check BasefeeSharingPctg
2024-07-26 09:02:03 +00:00

80 lines
2.8 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"`
BasefeeSharingPctg uint8 `json:"basefeeSharingPctg"`
}
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
enc.BasefeeSharingPctg = b.BasefeeSharingPctg
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"`
BasefeeSharingPctg *uint8 `json:"basefeeSharingPctg"`
}
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
if dec.BasefeeSharingPctg != nil {
b.BasefeeSharingPctg = *dec.BasefeeSharingPctg
}
return nil
}