Skip to content

Commit d748b1c

Browse files
core: read the raw blob from storage, do not unmarshal it unnecessarily
1 parent 080fabc commit d748b1c

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

core/blockchain_reader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,12 @@ func (bc *BlockChain) GetReceiptsByHash(hash common.Hash) types.Receipts {
232232

233233
// GetRawReceiptsByHash retrieves the receipts for all transactions in a given block
234234
// without deriving the internal fields and the Bloom.
235-
func (bc *BlockChain) GetRawReceiptsByHash(hash common.Hash) types.Receipts {
235+
func (bc *BlockChain) GetRawReceiptsByHash(hash common.Hash) rlp.RawValue {
236236
number := rawdb.ReadHeaderNumber(bc.db, hash)
237237
if number == nil {
238238
return nil
239239
}
240-
receipts := rawdb.ReadRawReceipts(bc.db, hash, *number)
240+
receipts := rawdb.ReadReceiptsRLP(bc.db, hash, *number)
241241
if receipts == nil {
242242
return nil
243243
}

eth/protocols/eth/handlers.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -303,18 +303,8 @@ func serviceGetReceiptsQuery69(chain *core.BlockChain, query GetReceiptsRequest)
303303
continue
304304
}
305305
}
306-
// Remove unnecessary fields
307-
var storageReceipts []*types.ReceiptForStorage
308-
for _, receipt := range results {
309-
storageReceipts = append(storageReceipts, (*types.ReceiptForStorage)(receipt))
310-
}
311-
// If known, encode and queue for response packet
312-
if encoded, err := rlp.EncodeToBytes(storageReceipts); err != nil {
313-
log.Error("Failed to encode receipt", "err", err)
314-
} else {
315-
receipts = append(receipts, encoded)
316-
bytes += len(encoded)
317-
}
306+
receipts = append(receipts, results)
307+
bytes += len(results)
318308
}
319309
return receipts
320310
}

0 commit comments

Comments
 (0)