aboutsummaryrefslogtreecommitdiffstats
path: root/core/state/statedb.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2016-05-31 05:07:51 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2016-05-31 05:07:51 +0800
commit5c39a1bb26813d05244a5408b20fb0b38c10c8b2 (patch)
treeaf9ebf86f6f863f9b23c502cb1699c604938fcd6 /core/state/statedb.go
parentab664c7e17009729d1083d8d4f7c37eb387012d3 (diff)
parent748d1c171d74fbf6b6051fd629d3c2204dd930e3 (diff)
downloadgo-tangerine-5c39a1bb26813d05244a5408b20fb0b38c10c8b2.tar
go-tangerine-5c39a1bb26813d05244a5408b20fb0b38c10c8b2.tar.gz
go-tangerine-5c39a1bb26813d05244a5408b20fb0b38c10c8b2.tar.bz2
go-tangerine-5c39a1bb26813d05244a5408b20fb0b38c10c8b2.tar.lz
go-tangerine-5c39a1bb26813d05244a5408b20fb0b38c10c8b2.tar.xz
go-tangerine-5c39a1bb26813d05244a5408b20fb0b38c10c8b2.tar.zst
go-tangerine-5c39a1bb26813d05244a5408b20fb0b38c10c8b2.zip
Merge pull request #2585 from karalabe/trie-dirty-tracking
core, core/state, trie: enterprise hand-tuned multi-level caching
Diffstat (limited to 'core/state/statedb.go')
-rw-r--r--core/state/statedb.go22
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