diff --git a/core/state/statedb.go b/core/state/statedb.go index 013e330a5c..dc5323f2b1 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -191,7 +191,7 @@ func (self *StateDB) SetTxContext(blockHash common.Hash, blockNum uint64, txHash if validator == nil { validator = &trie.NullCacheValidator{} } - storage := trie.NewDirectCache(self.trie, self.db, CachePrefix, &trie.NullCacheValidator{}, true) + storage := trie.NewDirectCache(self.trie, self.db, CachePrefix, validator, true) self.storage = trie.NewSecure(storage, self.db) } diff --git a/trie/directcache.go b/trie/directcache.go index 8beaf666e0..41a416526f 100644 --- a/trie/directcache.go +++ b/trie/directcache.go @@ -159,10 +159,6 @@ func (dc *DirectCache) TryDelete(key []byte) error { return dc.data.TryDelete(key) } -func (dc *DirectCache) Commit() (root common.Hash, err error) { - return dc.CommitTo(dc.db) -} - func (dc *DirectCache) CommitTo(dbw DatabaseWriter) (root common.Hash, err error) { directCacheWrites.Inc(int64(len(dc.dirty))) for k, _ := range dc.dirty { diff --git a/trie/secure_trie.go b/trie/secure_trie.go index 4f8af02cef..359c878d7e 100644 --- a/trie/secure_trie.go +++ b/trie/secure_trie.go @@ -34,7 +34,6 @@ type PersistentMap interface { TryUpdate(key, value []byte) error Delete(key []byte) TryDelete(key []byte) error - Commit() (root common.Hash, err error) CommitTo(db DatabaseWriter) (root common.Hash, err error) } @@ -140,18 +139,6 @@ func (t *SecureTrie) GetKey(shaKey []byte) []byte { return key } -// Commit writes all nodes and the secure hash pre-images to the database. -// Nodes are stored with their sha3 hash as the key. -// -// Committing flushes nodes from memory. Subsequent Get calls will load nodes -// from the database. -func (t *SecureTrie) Commit() (root common.Hash, err error) { - if err := t.CommitPreimages(); err != nil { - return common.Hash{}, err - } - return t.data.Commit() -} - func (t *SecureTrie) Iterator() *Iterator { return t.data.Iterator() } diff --git a/trie/secure_trie_test.go b/trie/secure_trie_test.go index 7b8907deeb..c0154b31b6 100644 --- a/trie/secure_trie_test.go +++ b/trie/secure_trie_test.go @@ -60,7 +60,7 @@ func makeTestSecureTrie() (ethdb.Database, *SecureTrie, map[string][]byte) { trie.Update(key, val) } } - trie.Commit() + trie.CommitTo(db) // Return the generated trie return db, trie, content @@ -110,7 +110,7 @@ func TestSecureGetKey(t *testing.T) { func TestSecureTrieConcurrency(t *testing.T) { // Create an initial trie and copy if for concurrent access - _, trie, _ := makeTestSecureTrie() + db, trie, _ := makeTestSecureTrie() threads := runtime.NumCPU() tries := make([]*SecureTrie, threads) @@ -139,7 +139,7 @@ func TestSecureTrieConcurrency(t *testing.T) { tries[index].Update(key, val) } } - tries[index].Commit() + tries[index].CommitTo(db) }(i) } // Wait for all threads to finish