Skip to content

Commit

Permalink
fetch geth upstread for ReadBorReceiptRLP
Browse files Browse the repository at this point in the history
  • Loading branch information
JekaMas committed Jan 25, 2023
1 parent a4fbd71 commit 2e838a6
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions core/rawdb/bor_receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,29 +48,19 @@ func HasBorReceipt(db ethdb.Reader, hash common.Hash, number uint64) bool {
return true
}

// ReadBorReceiptRLP retrieves the block receipt belonging to a block in RLP encoding.
func ReadBorReceiptRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue {
// First try to look up the data in ancient database. Extra hash
// comparison is necessary since ancient database only maintains
// the canonical data.

// Look up the data in leveldb.
data, _ := db.Get(borReceiptKey(number, hash))
if len(data) > 0 {
return data
}
// In the background freezer is moving data from leveldb to flatten files.
// So during the first check for ancient db, the data is not yet in there,
// but when we reach into leveldb, the data was already moved. That would
// result in a not found error.
data, _ = db.Ancient(freezerBorReceiptTable, number)
if len(data) > 0 {
h, _ := db.Ancient(freezerHashTable, number)
if common.BytesToHash(h) == hash {
return data
var data []byte
db.ReadAncients(func(reader ethdb.AncientReader) error {
// Check if the data is in ancients
if isCanon(reader, number, hash) {
data, _ = reader.Ancient(freezerBorReceiptTable, number)
return nil
}
}
return nil // Can't find the data anywhere.
// If not, try reading from leveldb
data, _ = db.Get(blockReceiptsKey(number, hash))
return nil
})
return data
}

// ReadRawBorReceipt retrieves the block receipt belonging to a block.
Expand Down

0 comments on commit 2e838a6

Please sign in to comment.