Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,18 @@ func (api *BlockChainAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rp
if block == nil || err != nil {
return nil, err
}
receipts, err := api.b.GetReceipts(ctx, block.Hash())
if err != nil {
return nil, err
var receipts types.Receipts
if blockNr, ok := blockNrOrHash.Number(); ok && blockNr == rpc.PendingBlockNumber {
var pendingBlock *types.Block
pendingBlock, receipts, _ = api.b.Pending()
if pendingBlock.Hash() != block.Hash() {
return nil, fmt.Errorf("pending block hash mismatch: %s vs %s", pendingBlock.Hash(), block.Hash())
}
Comment on lines +608 to +610
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels very dirty as we are forced to make two separate calls to miner.Pending() during execution of GetBlockReceipts.

If open to a larger refactor, one possibility is returning receipts in BlockByNumberOrHash

} else {
receipts, err = api.b.GetReceipts(ctx, block.Hash())
if err != nil {
return nil, err
}
}
txs := block.Transactions()
if len(txs) != len(receipts) {
Expand Down
Loading