From 3b26d83d72443c1d98a47d7fe79cfcaa80e8e935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Fri, 23 Sep 2016 08:35:39 +0300 Subject: [PATCH] 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. --- core/state/statedb.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/state/statedb.go b/core/state/statedb.go index 270cd44bd4..6d69a9e51e 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -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 {