forked from cerc-io/ipld-eth-server
new fields in eth.receipt_cids to index contract addresses seen in
logs; handle null dst/contract addrs in trxs/rcts
This commit is contained in:
@@ -94,8 +94,8 @@ func (pc *WatcherConverter) Convert(ethIPLDs eth.IPLDs) (*eth.CIDPayload, error)
|
||||
}
|
||||
// Tx data
|
||||
cids.TransactionCIDs[i] = eth.TxModel{
|
||||
Dst: shared.HandleNullAddr(tx.To()),
|
||||
Src: shared.HandleNullAddr(&from),
|
||||
Dst: shared.HandleNullAddrPointer(tx.To()),
|
||||
Src: shared.HandleNullAddr(from),
|
||||
TxHash: tx.Hash().String(),
|
||||
Index: int64(i),
|
||||
CID: txIPLD.CID,
|
||||
@@ -115,25 +115,27 @@ func (pc *WatcherConverter) Convert(ethIPLDs eth.IPLDs) (*eth.CIDPayload, error)
|
||||
}
|
||||
for i, receipt := range receipts {
|
||||
matchedTx := transactions[i]
|
||||
if matchedTx.To() != nil {
|
||||
receipt.ContractAddress = *transactions[i].To()
|
||||
}
|
||||
topicSets := make([][]string, 4)
|
||||
mappedContracts := make(map[string]bool) // use map to avoid duplicate addresses
|
||||
for _, log := range receipt.Logs {
|
||||
for i := range topicSets {
|
||||
if i < len(log.Topics) {
|
||||
topicSets[i] = append(topicSets[i], log.Topics[i].Hex())
|
||||
}
|
||||
for i, topic := range log.Topics {
|
||||
topicSets[i] = append(topicSets[i], topic.Hex())
|
||||
}
|
||||
mappedContracts[log.Address.String()] = true
|
||||
}
|
||||
logContracts := make([]string, 0, len(mappedContracts))
|
||||
for addr := range mappedContracts {
|
||||
logContracts = append(logContracts, addr)
|
||||
}
|
||||
// Rct data
|
||||
cids.ReceiptCIDs[matchedTx.Hash()] = eth.ReceiptModel{
|
||||
CID: ethIPLDs.Receipts[i].CID,
|
||||
Topic0s: topicSets[0],
|
||||
Topic1s: topicSets[1],
|
||||
Topic2s: topicSets[2],
|
||||
Topic3s: topicSets[3],
|
||||
Contract: receipt.ContractAddress.Hex(),
|
||||
CID: ethIPLDs.Receipts[i].CID,
|
||||
Topic0s: topicSets[0],
|
||||
Topic1s: topicSets[1],
|
||||
Topic2s: topicSets[2],
|
||||
Topic3s: topicSets[3],
|
||||
Contract: receipt.ContractAddress.Hex(),
|
||||
LogContracts: logContracts,
|
||||
}
|
||||
}
|
||||
minerReward := common2.CalcEthBlockReward(&header, uncles, transactions, receipts)
|
||||
|
||||
Reference in New Issue
Block a user