mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 02:40:45 +00:00
trie/bintrie: drop redundant zeroBlob local in DeleteAccount
The package already declares `var zero [32]byte` in binary_node.go, and both GetAccount and UpdateAccount reference `zero[:]` directly. The PR-introduced `zeroBlob` mirrored the older shadowing pattern from DeleteStorage but is unnecessary here — drop it and reuse the package-level value to match the canonical style on the create side.
This commit is contained in:
parent
090b757dc1
commit
7cf8c891ca
1 changed files with 5 additions and 6 deletions
|
|
@ -317,17 +317,16 @@ func (t *BinaryTrie) UpdateStorage(address common.Address, key, value []byte) er
|
||||||
// enumerate every slot of a given account.
|
// enumerate every slot of a given account.
|
||||||
func (t *BinaryTrie) DeleteAccount(addr common.Address) error {
|
func (t *BinaryTrie) DeleteAccount(addr common.Address) error {
|
||||||
var (
|
var (
|
||||||
zeroBlob [HashSize]byte
|
values = make([][]byte, StemNodeWidth)
|
||||||
values = make([][]byte, StemNodeWidth)
|
stem = GetBinaryTreeKey(addr, zero[:])
|
||||||
stem = GetBinaryTreeKey(addr, zero[:])
|
|
||||||
)
|
)
|
||||||
// Clear BasicData (nonce, balance, code size) and CodeHash.
|
// Clear BasicData (nonce, balance, code size) and CodeHash.
|
||||||
values[BasicDataLeafKey] = zeroBlob[:]
|
values[BasicDataLeafKey] = zero[:]
|
||||||
values[CodeHashLeafKey] = zeroBlob[:]
|
values[CodeHashLeafKey] = zero[:]
|
||||||
// Write a non-nil 32-byte sentinel at the deletion marker offset so
|
// Write a non-nil 32-byte sentinel at the deletion marker offset so
|
||||||
// GetAccount can tell "deleted" apart from "never existed" on a
|
// GetAccount can tell "deleted" apart from "never existed" on a
|
||||||
// subsequent read. See GetAccount's deletion branch around trie.go:219.
|
// subsequent read. See GetAccount's deletion branch around trie.go:219.
|
||||||
values[accountDeletedMarkerKey] = zeroBlob[:]
|
values[accountDeletedMarkerKey] = zero[:]
|
||||||
|
|
||||||
root, err := t.root.InsertValuesAtStem(stem, values, t.nodeResolver, 0)
|
root, err := t.root.InsertValuesAtStem(stem, values, t.nodeResolver, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue