github.com/shrimpyuk/bor@v0.2.15-0.20220224151350-fb4ec6020bae/core/bor_blockchain.go (about)

     1  package core
     2  
     3  import (
     4  	"github.com/ethereum/go-ethereum/common"
     5  	"github.com/ethereum/go-ethereum/core/rawdb"
     6  	"github.com/ethereum/go-ethereum/core/types"
     7  )
     8  
     9  // GetBorReceiptByHash retrieves the bor block receipt in a given block.
    10  func (bc *BlockChain) GetBorReceiptByHash(hash common.Hash) *types.Receipt {
    11  	if receipt, ok := bc.borReceiptsCache.Get(hash); ok {
    12  		return receipt.(*types.Receipt)
    13  	}
    14  
    15  	// read header from hash
    16  	number := rawdb.ReadHeaderNumber(bc.db, hash)
    17  	if number == nil {
    18  		return nil
    19  	}
    20  
    21  	// read bor reciept by hash and number
    22  	receipt := rawdb.ReadBorReceipt(bc.db, hash, *number)
    23  	if receipt == nil {
    24  		return nil
    25  	}
    26  
    27  	// add into bor receipt cache
    28  	bc.borReceiptsCache.Add(hash, receipt)
    29  	return receipt
    30  }