good morning!!!!

Skip to content
Snippets Groups Projects
Commit ae502ad6 authored by Shivam Sharma's avatar Shivam Sharma
Browse files

Some changes

parent 22e23070
Branches
Tags
No related merge requests found
...@@ -966,6 +966,29 @@ func (bc *BlockChain) GetReceiptsByHash(hash common.Hash) types.Receipts { ...@@ -966,6 +966,29 @@ func (bc *BlockChain) GetReceiptsByHash(hash common.Hash) types.Receipts {
return receipts return receipts
} }
// GetReceiptsByHash retrieves the receipts for all transactions in a given block.
func (bc *BlockChain) GetAllReceiptsByHash(hash common.Hash) types.Receipts {
if receipts, ok := bc.receiptsCache.Get(hash); ok {
return receipts.(types.Receipts)
}
number := rawdb.ReadHeaderNumber(bc.db, hash)
if number == nil {
return nil
}
receipts := rawdb.ReadReceipts(bc.db, hash, *number, bc.chainConfig)
if receipts == nil {
return nil
}
borReceipt := bc.GetBorReceiptByHash(hash)
if borReceipt != nil {
receipts = append(receipts, borReceipt)
}
bc.receiptsCache.Add(hash, receipts)
return receipts
}
// GetBlocksFromHash returns the block corresponding to hash and up to n-1 ancestors. // GetBlocksFromHash returns the block corresponding to hash and up to n-1 ancestors.
// [deprecated by eth/62] // [deprecated by eth/62]
func (bc *BlockChain) GetBlocksFromHash(hash common.Hash, n int) (blocks []*types.Block) { func (bc *BlockChain) GetBlocksFromHash(hash common.Hash, n int) (blocks []*types.Block) {
......
...@@ -214,17 +214,12 @@ func answerGetReceiptsQuery(backend Backend, query GetReceiptsPacket, peer *Peer ...@@ -214,17 +214,12 @@ func answerGetReceiptsQuery(backend Backend, query GetReceiptsPacket, peer *Peer
break break
} }
// Retrieve the requested block's receipts // Retrieve the requested block's receipts
results := backend.Chain().GetReceiptsByHash(hash) results := backend.Chain().GetAllReceiptsByHash(hash)
if results == nil { if results == nil {
if header := backend.Chain().GetHeaderByHash(hash); header == nil || header.ReceiptHash != types.EmptyRootHash { if header := backend.Chain().GetHeaderByHash(hash); header == nil || header.ReceiptHash != types.EmptyRootHash {
continue continue
} }
} }
borReceipt := backend.Chain().GetBorReceiptByHash(hash)
if borReceipt != nil {
results = append(results, borReceipt)
log.Info("Adding bor receipt to receipts query")
}
// If known, encode and queue for response packet // If known, encode and queue for response packet
if encoded, err := rlp.EncodeToBytes(results); err != nil { if encoded, err := rlp.EncodeToBytes(results); err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment