From 814c1e980e5df72ce5860505e9c2d490a334bc87 Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Tue, 1 Dec 2015 16:26:06 +0100 Subject: [PATCH] miner: bugfix, invalid transaction index in logs on local mined blocks --- miner/worker.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/miner/worker.go b/miner/worker.go index 754a6fc483..88c91c0e15 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -309,8 +309,19 @@ func (self *worker) wait() { l.BlockHash = block.Hash() } } + + txIndex := func(blck *types.Block, txHash common.Hash) int { + for i, tx := range blck.Transactions() { + if tx.Hash() == txHash { + return i + } + } + return 0 + } + for _, log := range work.state.Logs() { log.BlockHash = block.Hash() + log.TxIndex = uint(txIndex(block, log.TxHash)) } // check if canon block and write transactions