From 9209234e36c20422ee277f290306c0712f2ca354 Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Tue, 9 Mar 2021 12:59:01 -0800 Subject: [PATCH] fix getLogs for txnHash --- hmy/blockchain.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/hmy/blockchain.go b/hmy/blockchain.go index dd5ef0d66..0d47774f2 100644 --- a/hmy/blockchain.go +++ b/hmy/blockchain.go @@ -314,10 +314,19 @@ func (hmy *Harmony) GetLogs(ctx context.Context, blockHash common.Hash, isEth bo return nil, errors.New("Missing receipts") } if isEth { + block := hmy.BlockChain.GetBlockByHash(blockHash) + if block != nil { + return nil, errors.New("Missing block data") + } + txns := block.Transactions() for i, _ := range receipts { - for j, _ := range receipts[i].Logs { - // Override log txHash with receipt's - receipts[i].Logs[j].TxHash = receipts[i].TxHash + if i < len(txns) { + ethHash := txns[i].ConvertToEth().Hash() + receipts[i].TxHash = ethHash + for j, _ := range receipts[i].Logs { + // Override log txHash with receipt's + receipts[i].Logs[j].TxHash = ethHash + } } } }