diff options
author | obscuren <geffobscura@gmail.com> | 2015-04-08 23:14:58 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-04-08 23:15:45 +0800 |
commit | 1c872ddf4b1db51847a5d9d020e13d432e847f52 (patch) | |
tree | 72ec461427269a25165b58043f328fd374e143ee /core/block_processor.go | |
parent | 6284604b52e075e454e61f2933cadaaf9ded364b (diff) | |
download | go-tangerine-1c872ddf4b1db51847a5d9d020e13d432e847f52.tar go-tangerine-1c872ddf4b1db51847a5d9d020e13d432e847f52.tar.gz go-tangerine-1c872ddf4b1db51847a5d9d020e13d432e847f52.tar.bz2 go-tangerine-1c872ddf4b1db51847a5d9d020e13d432e847f52.tar.lz go-tangerine-1c872ddf4b1db51847a5d9d020e13d432e847f52.tar.xz go-tangerine-1c872ddf4b1db51847a5d9d020e13d432e847f52.tar.zst go-tangerine-1c872ddf4b1db51847a5d9d020e13d432e847f52.zip |
Changed how logs are being recorded
Logs are now recorded per transactions instead of tossing them out after
each transaction. This should also fix an issue with
`eth_getFilterLogs` (#629) Also now implemented are the `transactionHash,
blockHash, transactionIndex, logIndex` on logs. Closes #654.
Diffstat (limited to 'core/block_processor.go')
-rw-r--r-- | core/block_processor.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/core/block_processor.go b/core/block_processor.go index 39134c63e..7aded346a 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -73,7 +73,7 @@ func (sm *BlockProcessor) TransitionState(statedb *state.StateDB, parent, block func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, statedb *state.StateDB, block *types.Block, tx *types.Transaction, usedGas *big.Int, transientProcess bool) (*types.Receipt, *big.Int, error) { // If we are mining this block and validating we want to set the logs back to 0 - statedb.EmptyLogs() + //statedb.EmptyLogs() cb := statedb.GetStateObject(coinbase.Address()) _, gas, err := ApplyMessage(NewEnv(statedb, self.bc, tx, block), tx, cb) @@ -89,7 +89,9 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated cumulative := new(big.Int).Set(usedGas.Add(usedGas, gas)) receipt := types.NewReceipt(statedb.Root().Bytes(), cumulative) - receipt.SetLogs(statedb.Logs()) + + logs := statedb.GetLogs(tx.Hash()) + receipt.SetLogs(logs) receipt.Bloom = types.CreateBloom(types.Receipts{receipt}) glog.V(logger.Debug).Infoln(receipt) @@ -97,7 +99,6 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated // Notify all subscribers if !transientProcess { go self.eventMux.Post(TxPostEvent{tx}) - logs := statedb.Logs() go self.eventMux.Post(logs) } @@ -115,7 +116,9 @@ func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, state cumulativeSum = new(big.Int) ) - for _, tx := range txs { + for i, tx := range txs { + statedb.StartRecord(tx.Hash(), block.Hash(), i) + receipt, txGas, err := self.ApplyTransaction(coinbase, statedb, block, tx, totalUsedGas, transientProcess) if err != nil && (IsNonceErr(err) || state.IsGasLimitErr(err) || IsInvalidTxErr(err)) { return nil, err |