Skip to content

Commit 7a509b4

Browse files
princesinha19fjl
authored andcommitted
internal/ethapi: fix encoding of uncle headers and pending blocks (#20460)
Fixes #19024 Fixes #19332
1 parent 433937f commit 7a509b4

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎internal/ethapi/api.go‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ func (s *PublicBlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.B
642642
response, err := s.rpcMarshalBlock(block, true, fullTx)
643643
if err == nil && number == rpc.PendingBlockNumber {
644644
// Pending blocks need to nil out a few fields
645-
for _, field := range []string{"hash", "nonce", "miner"} {
645+
for _, field := range []string{"hash", "nonce", "miner", "number"} {
646646
response[field] = nil
647647
}
648648
}
@@ -1088,7 +1088,9 @@ func (s *PublicBlockChainAPI) rpcMarshalBlock(b *types.Block, inclTx bool, fullT
10881088
if err != nil {
10891089
return nil, err
10901090
}
1091-
fields["totalDifficulty"] = (*hexutil.Big)(s.b.GetTd(b.Hash()))
1091+
if inclTx {
1092+
fields["totalDifficulty"] = (*hexutil.Big)(s.b.GetTd(b.Hash()))
1093+
}
10921094
return fields, err
10931095
}
10941096

0 commit comments

Comments
 (0)