File tree Expand file tree Collapse file tree 3 files changed +13
-1
lines changed
Expand file tree Collapse file tree 3 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,9 @@ type Trie interface {
8686 // found in the database, a trie.MissingNodeError is returned.
8787 TryDelete (key []byte ) error
8888
89+ // TryDeleteAccount abstracts an account deletion from the trie.
90+ TryDeleteAccount (key []byte ) error
91+
8992 // Hash returns the root hash of the trie. It does not write to the database and
9093 // can be used even if the trie doesn't have one.
9194 Hash () common.Hash
Original file line number Diff line number Diff line change @@ -498,7 +498,9 @@ func (s *StateDB) deleteStateObject(obj *stateObject) {
498498
499499 // Delete the account from the trie
500500 addr := obj .Address ()
501- s .setError (s .trie .TryDelete (addr [:]))
501+ if err := s .trie .TryDeleteAccount (addr [:]); err != nil {
502+ s .setError (fmt .Errorf ("deleteStateObject (%x) error: %v" , addr [:], err ))
503+ }
502504}
503505
504506// DeleteAddress removes the address from the state trie.
Original file line number Diff line number Diff line change @@ -189,6 +189,13 @@ func (t *StateTrie) TryDelete(key []byte) error {
189189 return t .trie .TryDelete (hk )
190190}
191191
192+ // TryDeleteACcount abstracts an account deletion from the trie.
193+ func (t * StateTrie ) TryDeleteAccount (key []byte ) error {
194+ hk := t .hashKey (key )
195+ delete (t .getSecKeyCache (), string (hk ))
196+ return t .trie .TryDelete (hk )
197+ }
198+
192199// GetKey returns the sha3 Preimage of a hashed key that was
193200// previously used to store a value.
194201func (t * StateTrie ) GetKey (shaKey []byte ) []byte {
You can’t perform that action at this time.
0 commit comments