|
|
@ -16,25 +16,26 @@ var _ = (*headerMarshaling)(nil) |
|
|
|
// MarshalJSON marshals as JSON.
|
|
|
|
// MarshalJSON marshals as JSON.
|
|
|
|
func (h Header) MarshalJSON() ([]byte, error) { |
|
|
|
func (h Header) MarshalJSON() ([]byte, error) { |
|
|
|
type Header struct { |
|
|
|
type Header struct { |
|
|
|
ParentHash common.Hash `json:"parentHash" gencodec:"required"` |
|
|
|
ParentHash common.Hash `json:"parentHash" gencodec:"required"` |
|
|
|
UncleHash common.Hash `json:"sha3Uncles" gencodec:"required"` |
|
|
|
UncleHash common.Hash `json:"sha3Uncles" gencodec:"required"` |
|
|
|
Coinbase common.Address `json:"miner"` |
|
|
|
Coinbase common.Address `json:"miner"` |
|
|
|
Root common.Hash `json:"stateRoot" gencodec:"required"` |
|
|
|
Root common.Hash `json:"stateRoot" gencodec:"required"` |
|
|
|
TxHash common.Hash `json:"transactionsRoot" gencodec:"required"` |
|
|
|
TxHash common.Hash `json:"transactionsRoot" gencodec:"required"` |
|
|
|
ReceiptHash common.Hash `json:"receiptsRoot" gencodec:"required"` |
|
|
|
ReceiptHash common.Hash `json:"receiptsRoot" gencodec:"required"` |
|
|
|
Bloom Bloom `json:"logsBloom" gencodec:"required"` |
|
|
|
Bloom Bloom `json:"logsBloom" gencodec:"required"` |
|
|
|
Difficulty *hexutil.Big `json:"difficulty" gencodec:"required"` |
|
|
|
Difficulty *hexutil.Big `json:"difficulty" gencodec:"required"` |
|
|
|
Number *hexutil.Big `json:"number" gencodec:"required"` |
|
|
|
Number *hexutil.Big `json:"number" gencodec:"required"` |
|
|
|
GasLimit hexutil.Uint64 `json:"gasLimit" gencodec:"required"` |
|
|
|
GasLimit hexutil.Uint64 `json:"gasLimit" gencodec:"required"` |
|
|
|
GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"` |
|
|
|
GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"` |
|
|
|
Time hexutil.Uint64 `json:"timestamp" gencodec:"required"` |
|
|
|
Time hexutil.Uint64 `json:"timestamp" gencodec:"required"` |
|
|
|
Extra hexutil.Bytes `json:"extraData" gencodec:"required"` |
|
|
|
Extra hexutil.Bytes `json:"extraData" gencodec:"required"` |
|
|
|
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"` |
|
|
|
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"` |
|
|
|
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"` |
|
|
|
ExcessDataGas *big.Int `json:"excessDataGas" rlp:"optional"` |
|
|
|
ExcessDataGas *hexutil.Uint64 `json:"excessDataGas" rlp:"optional"` |
|
|
|
Hash common.Hash `json:"hash"` |
|
|
|
DataGasUsed *hexutil.Uint64 `json:"dataGasUsed" rlp:"optional"` |
|
|
|
|
|
|
|
Hash common.Hash `json:"hash"` |
|
|
|
} |
|
|
|
} |
|
|
|
var enc Header |
|
|
|
var enc Header |
|
|
|
enc.ParentHash = h.ParentHash |
|
|
|
enc.ParentHash = h.ParentHash |
|
|
@ -54,7 +55,8 @@ func (h Header) MarshalJSON() ([]byte, error) { |
|
|
|
enc.Nonce = h.Nonce |
|
|
|
enc.Nonce = h.Nonce |
|
|
|
enc.BaseFee = (*hexutil.Big)(h.BaseFee) |
|
|
|
enc.BaseFee = (*hexutil.Big)(h.BaseFee) |
|
|
|
enc.WithdrawalsHash = h.WithdrawalsHash |
|
|
|
enc.WithdrawalsHash = h.WithdrawalsHash |
|
|
|
enc.ExcessDataGas = h.ExcessDataGas |
|
|
|
enc.ExcessDataGas = (*hexutil.Uint64)(h.ExcessDataGas) |
|
|
|
|
|
|
|
enc.DataGasUsed = (*hexutil.Uint64)(h.DataGasUsed) |
|
|
|
enc.Hash = h.Hash() |
|
|
|
enc.Hash = h.Hash() |
|
|
|
return json.Marshal(&enc) |
|
|
|
return json.Marshal(&enc) |
|
|
|
} |
|
|
|
} |
|
|
@ -79,7 +81,8 @@ func (h *Header) UnmarshalJSON(input []byte) error { |
|
|
|
Nonce *BlockNonce `json:"nonce"` |
|
|
|
Nonce *BlockNonce `json:"nonce"` |
|
|
|
BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"` |
|
|
|
BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"` |
|
|
|
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"` |
|
|
|
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"` |
|
|
|
ExcessDataGas *big.Int `json:"excessDataGas" rlp:"optional"` |
|
|
|
ExcessDataGas *hexutil.Uint64 `json:"excessDataGas" rlp:"optional"` |
|
|
|
|
|
|
|
DataGasUsed *hexutil.Uint64 `json:"dataGasUsed" rlp:"optional"` |
|
|
|
} |
|
|
|
} |
|
|
|
var dec Header |
|
|
|
var dec Header |
|
|
|
if err := json.Unmarshal(input, &dec); err != nil { |
|
|
|
if err := json.Unmarshal(input, &dec); err != nil { |
|
|
@ -149,7 +152,10 @@ func (h *Header) UnmarshalJSON(input []byte) error { |
|
|
|
h.WithdrawalsHash = dec.WithdrawalsHash |
|
|
|
h.WithdrawalsHash = dec.WithdrawalsHash |
|
|
|
} |
|
|
|
} |
|
|
|
if dec.ExcessDataGas != nil { |
|
|
|
if dec.ExcessDataGas != nil { |
|
|
|
h.ExcessDataGas = dec.ExcessDataGas |
|
|
|
h.ExcessDataGas = (*uint64)(dec.ExcessDataGas) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if dec.DataGasUsed != nil { |
|
|
|
|
|
|
|
h.DataGasUsed = (*uint64)(dec.DataGasUsed) |
|
|
|
} |
|
|
|
} |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|