core/state: use dirty flag to avoid db writes

Until now the dirty flag was unset in intermediate root. That resulted
in not knowing whether a state object should be writte to disk or not.
Being removed in 1.4.12, we can rely on it to avoid a ton of writes.
This commit is contained in:
Péter Szilágyi 2016-09-23 08:35:39 +03:00
parent c9f5e4db76
commit 3b26d83d72

View file

@ -445,7 +445,7 @@ func (s *StateDB) commit(dbw trie.DatabaseWriter) (root common.Hash, err error)
// and just mark it for deletion in the trie.
s.DeleteStateObject(stateObject)
delete(s.all, addr)
} else {
} else if stateObject.dirty {
// Write any contract code associated with the state object
if stateObject.code != nil {
if err := dbw.Put(stateObject.CodeHash(), stateObject.code); err != nil {