Skip to content

Commit 2e838a6

Browse files
committed
fetch geth upstread for ReadBorReceiptRLP
1 parent a4fbd71 commit 2e838a6

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

core/rawdb/bor_receipt.go

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,29 +48,19 @@ func HasBorReceipt(db ethdb.Reader, hash common.Hash, number uint64) bool {
4848
return true
4949
}
5050

51-
// ReadBorReceiptRLP retrieves the block receipt belonging to a block in RLP encoding.
5251
func ReadBorReceiptRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue {
53-
// First try to look up the data in ancient database. Extra hash
54-
// comparison is necessary since ancient database only maintains
55-
// the canonical data.
56-
57-
// Look up the data in leveldb.
58-
data, _ := db.Get(borReceiptKey(number, hash))
59-
if len(data) > 0 {
60-
return data
61-
}
62-
// In the background freezer is moving data from leveldb to flatten files.
63-
// So during the first check for ancient db, the data is not yet in there,
64-
// but when we reach into leveldb, the data was already moved. That would
65-
// result in a not found error.
66-
data, _ = db.Ancient(freezerBorReceiptTable, number)
67-
if len(data) > 0 {
68-
h, _ := db.Ancient(freezerHashTable, number)
69-
if common.BytesToHash(h) == hash {
70-
return data
52+
var data []byte
53+
db.ReadAncients(func(reader ethdb.AncientReader) error {
54+
// Check if the data is in ancients
55+
if isCanon(reader, number, hash) {
56+
data, _ = reader.Ancient(freezerBorReceiptTable, number)
57+
return nil
7158
}
72-
}
73-
return nil // Can't find the data anywhere.
59+
// If not, try reading from leveldb
60+
data, _ = db.Get(blockReceiptsKey(number, hash))
61+
return nil
62+
})
63+
return data
7464
}
7565

7666
// ReadRawBorReceipt retrieves the block receipt belonging to a block.

0 commit comments

Comments
 (0)