go-ethereum/core/bor_blockchain.go
2023-06-15 15:48:26 +02:00

31 lines
735 B
Go

package core
import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types"
)
// GetBorReceiptByHash retrieves the bor block receipt in a given block.
func (bc *BlockChain) GetBorReceiptByHash(hash common.Hash) *types.Receipt {
if receipt, ok := bc.borReceiptsCache.Get(hash); ok {
return receipt
}
// read header from hash
number := rawdb.ReadHeaderNumber(bc.db, hash)
if number == nil {
return nil
}
// read bor reciept by hash and number
receipt := rawdb.ReadBorReceipt(bc.db, hash, *number, bc.chainConfig)
if receipt == nil {
return nil
}
// add into bor receipt cache
bc.borReceiptsCache.Add(hash, receipt)
return receipt
}