aboutsummaryrefslogtreecommitdiffstats
path: root/miner/worker.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-10-04 18:36:02 +0800
committerFelix Lange <fjl@twurst.com>2016-10-06 22:25:17 +0800
commit46a527d01485102a798bf27f24622fc6274f58d9 (patch)
tree0e99fdcc8befc54548db579b18eeab29bf2189f2 /miner/worker.go
parente97b30169b97adefa6e5067df1e307852b226583 (diff)
downloadgo-tangerine-46a527d01485102a798bf27f24622fc6274f58d9.tar
go-tangerine-46a527d01485102a798bf27f24622fc6274f58d9.tar.gz
go-tangerine-46a527d01485102a798bf27f24622fc6274f58d9.tar.bz2
go-tangerine-46a527d01485102a798bf27f24622fc6274f58d9.tar.lz
go-tangerine-46a527d01485102a798bf27f24622fc6274f58d9.tar.xz
go-tangerine-46a527d01485102a798bf27f24622fc6274f58d9.tar.zst
go-tangerine-46a527d01485102a798bf27f24622fc6274f58d9.zip
[release/1.4.16] core/state: implement reverts by journaling all changes
This commit replaces the deep-copy based state revert mechanism with a linear complexity journal. This commit also hides several internal StateDB methods to limit the number of ways in which calling code can use the journal incorrectly. As usual consultation and bug fixes to the initial implementation were provided by @karalabe, @obscuren and @Arachnid. Thank you! (cherry picked from commit 1f1ea18b5414bea22332bb4fce53cc95b5c6a07d)
Diffstat (limited to 'miner/worker.go')
-rw-r--r--miner/worker.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/miner/worker.go b/miner/worker.go
index 41db117bf..f1dac2345 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -173,7 +173,7 @@ func (self *worker) pending() (*types.Block, *state.StateDB) {
self.current.receipts,
), self.current.state
}
- return self.current.Block, self.current.state
+ return self.current.Block, self.current.state.Copy()
}
func (self *worker) start() {
@@ -665,7 +665,7 @@ func (env *Work) commitTransactions(mux *event.TypeMux, transactions types.Trans
}
func (env *Work) commitTransaction(tx *types.Transaction, bc *core.BlockChain, gp *core.GasPool) (error, vm.Logs) {
- snap := env.state.Copy()
+ snap := env.state.Snapshot()
// this is a bit of a hack to force jit for the miners
config := env.config.VmConfig
@@ -676,7 +676,7 @@ func (env *Work) commitTransaction(tx *types.Transaction, bc *core.BlockChain, g
receipt, logs, _, err := core.ApplyTransaction(env.config, bc, gp, env.state, env.header, tx, env.header.GasUsed, config)
if err != nil {
- env.state.Set(snap)
+ env.state.RevertToSnapshot(snap)
return err, nil
}
env.txs = append(env.txs, tx)