diff options
author | Felix Lange <fjl@twurst.com> | 2016-10-04 18:36:02 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2016-10-06 21:32:16 +0800 |
commit | 1f1ea18b5414bea22332bb4fce53cc95b5c6a07d (patch) | |
tree | d1aa3051f9c4d9f33a24519c18b70f0dd2f00644 /miner/worker.go | |
parent | ab7adb0027dbcf09cf75a533be356c1e24c46c90 (diff) | |
download | go-tangerine-1f1ea18b5414bea22332bb4fce53cc95b5c6a07d.tar go-tangerine-1f1ea18b5414bea22332bb4fce53cc95b5c6a07d.tar.gz go-tangerine-1f1ea18b5414bea22332bb4fce53cc95b5c6a07d.tar.bz2 go-tangerine-1f1ea18b5414bea22332bb4fce53cc95b5c6a07d.tar.lz go-tangerine-1f1ea18b5414bea22332bb4fce53cc95b5c6a07d.tar.xz go-tangerine-1f1ea18b5414bea22332bb4fce53cc95b5c6a07d.tar.zst go-tangerine-1f1ea18b5414bea22332bb4fce53cc95b5c6a07d.zip |
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!
Diffstat (limited to 'miner/worker.go')
-rw-r--r-- | miner/worker.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/miner/worker.go b/miner/worker.go index ac1ef5ba3..e5348cef4 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -171,7 +171,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() { @@ -618,7 +618,7 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB } 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 @@ -629,7 +629,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) |