process receipts from payload instead of retreiving over additional rpc call

This commit is contained in:
Ian Norden 2019-08-05 10:47:03 -05:00
parent 13d09e15c1
commit 2244d1869f

View File

@ -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 // txMeta will have same index as its corresponding trx in the convertedPayload.BlockBody
convertedPayload.TrxMetaData = append(convertedPayload.TrxMetaData, txMeta) convertedPayload.TrxMetaData = append(convertedPayload.TrxMetaData, txMeta)
}
// Retrieve receipt for this transaction // Decode receipts for this block
gethReceipt, err := pc.client.TransactionReceipt(context.Background(), trx.Hash()) receipts := make(types.Receipts, 0)
if err != nil { err = rlp.DecodeBytes(payload.ReceiptsRlp, &receipts)
return nil, err if err != nil {
} return nil, err
}
for _, receipt := range receipts {
// Extract topic0 data from the receipt's logs for indexing // Extract topic0 data from the receipt's logs for indexing
rctMeta := &ReceiptMetaData{ rctMeta := &ReceiptMetaData{
Topic0s: make([]string, 0, len(gethReceipt.Logs)), Topic0s: make([]string, 0, len(receipt.Logs)),
ContractAddress: gethReceipt.ContractAddress.Hex(), ContractAddress: receipt.ContractAddress.Hex(),
} }
for _, log := range gethReceipt.Logs { for _, log := range receipt.Logs {
if len(log.Topics[0]) < 1 { if len(log.Topics) < 1 {
continue continue
} }
rctMeta.Topic0s = append(rctMeta.Topic0s, log.Topics[0].Hex()) rctMeta.Topic0s = append(rctMeta.Topic0s, log.Topics[0].Hex())
} }
// receipt and rctMeta will have same indexes // 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) convertedPayload.ReceiptMetaData = append(convertedPayload.ReceiptMetaData, rctMeta)
} }