diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 9c74f1fe7a6168e21232b3806551b95cd91a18e7..6cd70a755ee2e88fa968b0df94a58593e522e4c6 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -742,16 +742,19 @@ func ReadReceiptsByHashDeprecated(db ethdb.Getter, hash common.Hash) types.Recei return receipts } -func ReadReceiptsByHash(db ethdb.Tx, hash common.Hash) types.Receipts { - number := ReadHeaderNumber(db, hash) - if number == nil { - return nil +func ReadReceiptsByHash(db ethdb.Tx, hash common.Hash) (types.Receipts, error) { + b, s, err := ReadBlockByHashWithSenders(db, hash) + if err != nil { + return nil, err } - receipts := ReadReceipts(db, hash, *number) + if b == nil { + return nil, nil + } + receipts := ReadReceipts(db, b, s) if receipts == nil { - return nil + return nil, nil } - return receipts + return receipts, nil } func ReadReceiptsByNumber(db ethdb.Getter, number uint64) types.Receipts { h, _ := ReadCanonicalHash(db, number) diff --git a/eth/protocols/eth/getters_test.go b/eth/protocols/eth/getters_test.go index c111c323b2a7d36f61d554a40aa874c179d8d103..129583d1cdab2cb9a6e4564c268fd446731a2fb0 100644 --- a/eth/protocols/eth/getters_test.go +++ b/eth/protocols/eth/getters_test.go @@ -83,7 +83,11 @@ func testGetBlockReceipts(t *testing.T, protocol uint) { hashes = append(hashes, block.Hash()) // If known, encode and queue for response packet - encoded, err := rlp.EncodeToBytes(rawdb.ReadReceiptsByHash(tx, block.Hash())) + r, err := rawdb.ReadReceiptsByHash(tx, block.Hash()) + if err != nil { + return err + } + encoded, err := rlp.EncodeToBytes(r) require.NoError(t, err) receipts = append(receipts, encoded) }