mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
gencodec
This commit is contained in:
parent
f1e523a142
commit
57148478e9
2 changed files with 28 additions and 2 deletions
|
|
@ -134,6 +134,8 @@ type headerMarshaling struct {
|
||||||
Extra hexutil.Bytes
|
Extra hexutil.Bytes
|
||||||
BaseFee *hexutil.Big
|
BaseFee *hexutil.Big
|
||||||
Hash common.Hash `json:"hash"` // adds call to Hash() in MarshalJSON
|
Hash common.Hash `json:"hash"` // adds call to Hash() in MarshalJSON
|
||||||
|
BlobGasUsed *hexutil.Uint64
|
||||||
|
ExcessBlobGas *hexutil.Uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hash returns the block hash of the header, which is simply the keccak256 hash of its
|
// Hash returns the block hash of the header, which is simply the keccak256 hash of its
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,15 @@ func (h Header) MarshalJSON() ([]byte, error) {
|
||||||
MixDigest common.Hash `json:"mixHash"`
|
MixDigest common.Hash `json:"mixHash"`
|
||||||
Nonce BlockNonce `json:"nonce"`
|
Nonce BlockNonce `json:"nonce"`
|
||||||
BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"`
|
BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"`
|
||||||
|
BlockSignature []byte `json:"-" rlp:"-"`
|
||||||
|
IsEuclidV2 bool `json:"-" rlp:"-"`
|
||||||
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
|
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
|
||||||
Hash common.Hash `json:"hash"`
|
|
||||||
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed" rlp:"optional"`
|
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed" rlp:"optional"`
|
||||||
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"`
|
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"`
|
||||||
ParentBeaconRoot *common.Hash `json:"parentBeaconBlockRoot" rlp:"optional"`
|
ParentBeaconRoot *common.Hash `json:"parentBeaconBlockRoot" rlp:"optional"`
|
||||||
|
RequestsHash *common.Hash `json:"requestsHash" rlp:"optional"`
|
||||||
|
Requested bool `json:"-" rlp:"-"`
|
||||||
|
Hash common.Hash `json:"hash"`
|
||||||
}
|
}
|
||||||
var enc Header
|
var enc Header
|
||||||
enc.ParentHash = h.ParentHash
|
enc.ParentHash = h.ParentHash
|
||||||
|
|
@ -55,11 +59,15 @@ func (h Header) MarshalJSON() ([]byte, error) {
|
||||||
enc.MixDigest = h.MixDigest
|
enc.MixDigest = h.MixDigest
|
||||||
enc.Nonce = h.Nonce
|
enc.Nonce = h.Nonce
|
||||||
enc.BaseFee = (*hexutil.Big)(h.BaseFee)
|
enc.BaseFee = (*hexutil.Big)(h.BaseFee)
|
||||||
|
enc.BlockSignature = h.BlockSignature
|
||||||
|
enc.IsEuclidV2 = h.IsEuclidV2
|
||||||
enc.WithdrawalsHash = h.WithdrawalsHash
|
enc.WithdrawalsHash = h.WithdrawalsHash
|
||||||
enc.Hash = h.Hash()
|
|
||||||
enc.BlobGasUsed = (*hexutil.Uint64)(h.BlobGasUsed)
|
enc.BlobGasUsed = (*hexutil.Uint64)(h.BlobGasUsed)
|
||||||
enc.ExcessBlobGas = (*hexutil.Uint64)(h.ExcessBlobGas)
|
enc.ExcessBlobGas = (*hexutil.Uint64)(h.ExcessBlobGas)
|
||||||
enc.ParentBeaconRoot = h.ParentBeaconRoot
|
enc.ParentBeaconRoot = h.ParentBeaconRoot
|
||||||
|
enc.RequestsHash = h.RequestsHash
|
||||||
|
enc.Requested = h.Requested
|
||||||
|
enc.Hash = h.Hash()
|
||||||
return json.Marshal(&enc)
|
return json.Marshal(&enc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,10 +90,14 @@ func (h *Header) UnmarshalJSON(input []byte) error {
|
||||||
MixDigest *common.Hash `json:"mixHash"`
|
MixDigest *common.Hash `json:"mixHash"`
|
||||||
Nonce *BlockNonce `json:"nonce"`
|
Nonce *BlockNonce `json:"nonce"`
|
||||||
BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"`
|
BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"`
|
||||||
|
BlockSignature []byte `json:"-" rlp:"-"`
|
||||||
|
IsEuclidV2 *bool `json:"-" rlp:"-"`
|
||||||
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
|
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
|
||||||
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed" rlp:"optional"`
|
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed" rlp:"optional"`
|
||||||
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"`
|
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"`
|
||||||
ParentBeaconRoot *common.Hash `json:"parentBeaconBlockRoot" rlp:"optional"`
|
ParentBeaconRoot *common.Hash `json:"parentBeaconBlockRoot" rlp:"optional"`
|
||||||
|
RequestsHash *common.Hash `json:"requestsHash" rlp:"optional"`
|
||||||
|
Requested *bool `json:"-" rlp:"-"`
|
||||||
}
|
}
|
||||||
var dec Header
|
var dec Header
|
||||||
if err := json.Unmarshal(input, &dec); err != nil {
|
if err := json.Unmarshal(input, &dec); err != nil {
|
||||||
|
|
@ -151,6 +163,12 @@ func (h *Header) UnmarshalJSON(input []byte) error {
|
||||||
if dec.BaseFee != nil {
|
if dec.BaseFee != nil {
|
||||||
h.BaseFee = (*big.Int)(dec.BaseFee)
|
h.BaseFee = (*big.Int)(dec.BaseFee)
|
||||||
}
|
}
|
||||||
|
if dec.BlockSignature != nil {
|
||||||
|
h.BlockSignature = dec.BlockSignature
|
||||||
|
}
|
||||||
|
if dec.IsEuclidV2 != nil {
|
||||||
|
h.IsEuclidV2 = *dec.IsEuclidV2
|
||||||
|
}
|
||||||
if dec.WithdrawalsHash != nil {
|
if dec.WithdrawalsHash != nil {
|
||||||
h.WithdrawalsHash = dec.WithdrawalsHash
|
h.WithdrawalsHash = dec.WithdrawalsHash
|
||||||
}
|
}
|
||||||
|
|
@ -163,5 +181,11 @@ func (h *Header) UnmarshalJSON(input []byte) error {
|
||||||
if dec.ParentBeaconRoot != nil {
|
if dec.ParentBeaconRoot != nil {
|
||||||
h.ParentBeaconRoot = dec.ParentBeaconRoot
|
h.ParentBeaconRoot = dec.ParentBeaconRoot
|
||||||
}
|
}
|
||||||
|
if dec.RequestsHash != nil {
|
||||||
|
h.RequestsHash = dec.RequestsHash
|
||||||
|
}
|
||||||
|
if dec.Requested != nil {
|
||||||
|
h.Requested = *dec.Requested
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue