diff options
author | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-07-01 05:49:34 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-07-04 08:51:36 +0800 |
commit | 08caeedd842526373d30a929e63101a5fe7fda55 (patch) | |
tree | d5aeeaa092108c34f3daec916972a7b7cae683ca /core/state/statedb.go | |
parent | 6f69b4d61f1278ea2d9351667512a1202403eaff (diff) | |
download | dexon-08caeedd842526373d30a929e63101a5fe7fda55.tar dexon-08caeedd842526373d30a929e63101a5fe7fda55.tar.gz dexon-08caeedd842526373d30a929e63101a5fe7fda55.tar.bz2 dexon-08caeedd842526373d30a929e63101a5fe7fda55.tar.lz dexon-08caeedd842526373d30a929e63101a5fe7fda55.tar.xz dexon-08caeedd842526373d30a929e63101a5fe7fda55.tar.zst dexon-08caeedd842526373d30a929e63101a5fe7fda55.zip |
core, core/state: only write necessary state. Skip intermediate
Diffstat (limited to 'core/state/statedb.go')
-rw-r--r-- | core/state/statedb.go | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/core/state/statedb.go b/core/state/statedb.go index f6f63f329..bd4ff6ff3 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -18,6 +18,7 @@ import ( type StateDB struct { db common.Database trie *trie.SecureTrie + root common.Hash stateObjects map[string]*StateObject @@ -31,7 +32,7 @@ type StateDB struct { // Create a new state from a given trie func New(root common.Hash, db common.Database) *StateDB { trie := trie.NewSecure(root[:], db) - return &StateDB{db: db, trie: trie, stateObjects: make(map[string]*StateObject), refund: new(big.Int), logs: make(map[common.Hash]Logs)} + return &StateDB{root: root, db: db, trie: trie, stateObjects: make(map[string]*StateObject), refund: new(big.Int), logs: make(map[common.Hash]Logs)} } func (self *StateDB) PrintRoot() { @@ -185,7 +186,7 @@ func (self *StateDB) DeleteStateObject(stateObject *StateObject) { addr := stateObject.Address() self.trie.Delete(addr[:]) - delete(self.stateObjects, addr.Str()) + //delete(self.stateObjects, addr.Str()) } // Retrieve a state object given my the address. Nil if not found @@ -340,6 +341,23 @@ func (self *StateDB) Update() { } } +func (self *StateDB) CleanUpdate() { + self.trie = trie.NewSecure(self.root[:], self.db) + + self.refund = new(big.Int) + + for _, stateObject := range self.stateObjects { + if stateObject.remove { + self.DeleteStateObject(stateObject) + } else { + stateObject.Update() + + self.UpdateStateObject(stateObject) + } + stateObject.dirty = false + } +} + // Debug stuff func (self *StateDB) CreateOutputForDiff() { for _, stateObject := range self.stateObjects { |