diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-05-19 18:24:14 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-06-06 21:21:39 +0800 |
commit | af53767e162e59e45e18aad61fa79b85d74f0aeb (patch) | |
tree | 0eb4c9e7a4c5ed61fc8dae401cf7ce784545f8d2 /core/state | |
parent | 7632acf6b432795128eb02990fe2cd2b7cea008a (diff) | |
download | go-tangerine-af53767e162e59e45e18aad61fa79b85d74f0aeb.tar go-tangerine-af53767e162e59e45e18aad61fa79b85d74f0aeb.tar.gz go-tangerine-af53767e162e59e45e18aad61fa79b85d74f0aeb.tar.bz2 go-tangerine-af53767e162e59e45e18aad61fa79b85d74f0aeb.tar.lz go-tangerine-af53767e162e59e45e18aad61fa79b85d74f0aeb.tar.xz go-tangerine-af53767e162e59e45e18aad61fa79b85d74f0aeb.tar.zst go-tangerine-af53767e162e59e45e18aad61fa79b85d74f0aeb.zip |
[release/1.4.6] core, core/state, trie: enterprise hand-tuned multi-level caching
(cherry picked from commit 748d1c171d74fbf6b6051fd629d3c2204dd930e3)
Diffstat (limited to 'core/state')
-rw-r--r-- | core/state/statedb.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/core/state/statedb.go b/core/state/statedb.go index 27bc38373..70673799e 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -68,6 +68,28 @@ func New(root common.Hash, db ethdb.Database) (*StateDB, error) { }, nil } +// Reset clears out all emphemeral state objects from the state db, but keeps +// the underlying state trie to avoid reloading data for the next operations. +func (self *StateDB) Reset(root common.Hash) error { + var ( + err error + tr = self.trie + ) + if self.trie.Hash() != root { + if tr, err = trie.NewSecure(root, self.db); err != nil { + return err + } + } + *self = StateDB{ + db: self.db, + trie: tr, + stateObjects: make(map[string]*StateObject), + refund: new(big.Int), + logs: make(map[common.Hash]vm.Logs), + } + return nil +} + func (self *StateDB) StartRecord(thash, bhash common.Hash, ti int) { self.thash = thash self.bhash = bhash |