Skip to content

Commit

Permalink
Remove duplicate update/delete on tire (#1001)
Browse files Browse the repository at this point in the history
* rm duplicate update/delete on tire
* rm useless code
  • Loading branch information
qinglin89 authored Jul 26, 2022
1 parent dd3b3a6 commit 71f0caa
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions core/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,14 +411,9 @@ func (s *StateObject) updateTrie(db Database) Trie {
}
s.originStorage[key] = value
var v []byte
if (value == common.Hash{}) {
s.setError(tr.TryDelete(key[:]))
s.db.StorageDeleted += 1
} else {
if value != (common.Hash{}) {
// Encoding []byte cannot fail, ok to ignore the error.
v, _ = rlp.EncodeToBytes(common.TrimLeftZeroes(value[:]))
s.setError(tr.TryUpdate(key[:], v))
s.db.StorageUpdated += 1
}
dirtyStorage[key] = v
}
Expand Down Expand Up @@ -447,10 +442,10 @@ func (s *StateObject) updateTrie(db Database) Trie {
storage = make(map[string][]byte, len(dirtyStorage))
s.db.snapStorage[s.address] = storage
}
s.db.snapStorageMux.Unlock()
for key, value := range dirtyStorage {
storage[string(key[:])] = value
}
s.db.snapStorageMux.Unlock()
}()
}
wg.Wait()
Expand Down

0 comments on commit 71f0caa

Please sign in to comment.