From 2244d1869f5dfe62859d6112db77c02e92c2e9f6 Mon Sep 17 00:00:00 2001 From: Ian Norden Date: Mon, 5 Aug 2019 10:47:03 -0500 Subject: [PATCH] process receipts from payload instead of retreiving over additional rpc call --- pkg/ipfs/converter.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/pkg/ipfs/converter.go b/pkg/ipfs/converter.go index 179d5b2a..0aa52ec9 100644 --- a/pkg/ipfs/converter.go +++ b/pkg/ipfs/converter.go @@ -78,25 +78,28 @@ func (pc *Converter) Convert(payload statediff.Payload) (*IPLDPayload, error) { } // txMeta will have same index as its corresponding trx in the convertedPayload.BlockBody convertedPayload.TrxMetaData = append(convertedPayload.TrxMetaData, txMeta) + } - // Retrieve receipt for this transaction - gethReceipt, err := pc.client.TransactionReceipt(context.Background(), trx.Hash()) - if err != nil { - return nil, err - } + // Decode receipts for this block + receipts := make(types.Receipts, 0) + err = rlp.DecodeBytes(payload.ReceiptsRlp, &receipts) + if err != nil { + return nil, err + } + for _, receipt := range receipts { // Extract topic0 data from the receipt's logs for indexing rctMeta := &ReceiptMetaData{ - Topic0s: make([]string, 0, len(gethReceipt.Logs)), - ContractAddress: gethReceipt.ContractAddress.Hex(), + Topic0s: make([]string, 0, len(receipt.Logs)), + ContractAddress: receipt.ContractAddress.Hex(), } - for _, log := range gethReceipt.Logs { - if len(log.Topics[0]) < 1 { + for _, log := range receipt.Logs { + if len(log.Topics) < 1 { continue } rctMeta.Topic0s = append(rctMeta.Topic0s, log.Topics[0].Hex()) } // receipt and rctMeta will have same indexes - convertedPayload.Receipts = append(convertedPayload.Receipts, gethReceipt) + convertedPayload.Receipts = append(convertedPayload.Receipts, receipt) convertedPayload.ReceiptMetaData = append(convertedPayload.ReceiptMetaData, rctMeta) }