mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 10:50:44 +00:00
parent
e4fd044fa0
commit
80159e5854
3 changed files with 11 additions and 1 deletions
|
|
@ -86,6 +86,9 @@ type Trie interface {
|
||||||
// found in the database, a trie.MissingNodeError is returned.
|
// found in the database, a trie.MissingNodeError is returned.
|
||||||
TryDelete(key []byte) error
|
TryDelete(key []byte) error
|
||||||
|
|
||||||
|
// TryDeleteAccount abstracts an account deletion from the trie.
|
||||||
|
TryDeleteAccount(key []byte) error
|
||||||
|
|
||||||
// Hash returns the root hash of the trie. It does not write to the database and
|
// Hash returns the root hash of the trie. It does not write to the database and
|
||||||
// can be used even if the trie doesn't have one.
|
// can be used even if the trie doesn't have one.
|
||||||
Hash() common.Hash
|
Hash() common.Hash
|
||||||
|
|
|
||||||
|
|
@ -521,7 +521,7 @@ func (s *StateDB) deleteStateObject(obj *stateObject) {
|
||||||
|
|
||||||
// Delete the account from the trie
|
// Delete the account from the trie
|
||||||
addr := obj.Address()
|
addr := obj.Address()
|
||||||
if err := s.trie.TryDelete(addr[:]); err != nil {
|
if err := s.trie.TryDeleteAccount(addr[:]); err != nil {
|
||||||
s.setError(fmt.Errorf("deleteStateObject (%x) error: %v", addr[:], err))
|
s.setError(fmt.Errorf("deleteStateObject (%x) error: %v", addr[:], err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,13 @@ func (t *StateTrie) TryDelete(key []byte) error {
|
||||||
return t.trie.TryDelete(hk)
|
return t.trie.TryDelete(hk)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TryDeleteACcount abstracts an account deletion from the trie.
|
||||||
|
func (t *StateTrie) TryDeleteAccount(key []byte) error {
|
||||||
|
hk := t.hashKey(key)
|
||||||
|
delete(t.getSecKeyCache(), string(hk))
|
||||||
|
return t.trie.TryDelete(hk)
|
||||||
|
}
|
||||||
|
|
||||||
// GetKey returns the sha3 Preimage of a hashed key that was
|
// GetKey returns the sha3 Preimage of a hashed key that was
|
||||||
// previously used to store a value.
|
// previously used to store a value.
|
||||||
func (t *StateTrie) GetKey(shaKey []byte) []byte {
|
func (t *StateTrie) GetKey(shaKey []byte) []byte {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue