core/types: make "miner" optional in Header JSON (#24666)
"miner" is not set for pending block responses in some cases. Fixes #24632
This commit is contained in:
parent
a41619f04e
commit
f37f2a9fbe
@ -100,7 +100,7 @@ func (n *BlockNonce) UnmarshalText(input []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" gencodec:"required"`
|
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"`
|
||||||
|
@ -18,7 +18,7 @@ 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" gencodec:"required"`
|
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"`
|
||||||
@ -60,7 +60,7 @@ func (h *Header) UnmarshalJSON(input []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" gencodec:"required"`
|
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"`
|
||||||
@ -87,10 +87,9 @@ func (h *Header) UnmarshalJSON(input []byte) error {
|
|||||||
return errors.New("missing required field 'sha3Uncles' for Header")
|
return errors.New("missing required field 'sha3Uncles' for Header")
|
||||||
}
|
}
|
||||||
h.UncleHash = *dec.UncleHash
|
h.UncleHash = *dec.UncleHash
|
||||||
if dec.Coinbase == nil {
|
if dec.Coinbase != nil {
|
||||||
return errors.New("missing required field 'miner' for Header")
|
h.Coinbase = *dec.Coinbase
|
||||||
}
|
}
|
||||||
h.Coinbase = *dec.Coinbase
|
|
||||||
if dec.Root == nil {
|
if dec.Root == nil {
|
||||||
return errors.New("missing required field 'stateRoot' for Header")
|
return errors.New("missing required field 'stateRoot' for Header")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user