From c1729b7f5287699469d22faf134a7c1ab0c07651 Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Wed, 10 Dec 2025 16:07:37 +0800 Subject: [PATCH] triedb/pathdb: polish code --- triedb/pathdb/disklayer.go | 3 +-- triedb/pathdb/flush.go | 3 +-- triedb/pathdb/lookup.go | 7 +++++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/triedb/pathdb/disklayer.go b/triedb/pathdb/disklayer.go index 7ad31ced41..b9c308c5b6 100644 --- a/triedb/pathdb/disklayer.go +++ b/triedb/pathdb/disklayer.go @@ -275,8 +275,7 @@ func (dl *diskLayer) storage(accountHash, storageHash common.Hash, depth int) ([ // If the layer is being generated, ensure the requested storage slot // has already been covered by the generator. - skey := storageKey(accountHash, storageHash) - key := skey[:] + key := storageKeySlice(accountHash, storageHash) marker := dl.genMarker() if marker != nil && bytes.Compare(key, marker) > 0 { return nil, errNotCoveredYet diff --git a/triedb/pathdb/flush.go b/triedb/pathdb/flush.go index 1be684a257..4f816cf6a6 100644 --- a/triedb/pathdb/flush.go +++ b/triedb/pathdb/flush.go @@ -116,8 +116,7 @@ func writeStates(batch ethdb.Batch, genMarker []byte, accountData map[common.Has continue } slots += 1 - skey := storageKey(addrHash, storageHash) - key := skey[:] + key := storageKeySlice(addrHash, storageHash) if len(blob) == 0 { rawdb.DeleteStorageSnapshot(batch, addrHash, storageHash) if clean != nil { diff --git a/triedb/pathdb/lookup.go b/triedb/pathdb/lookup.go index 8b092730f8..719546f410 100644 --- a/triedb/pathdb/lookup.go +++ b/triedb/pathdb/lookup.go @@ -33,6 +33,13 @@ func storageKey(accountHash common.Hash, slotHash common.Hash) [64]byte { return key } +// storageKeySlice returns a key for uniquely identifying the storage slot in +// the slice format. +func storageKeySlice(accountHash common.Hash, slotHash common.Hash) []byte { + key := storageKey(accountHash, slotHash) + return key[:] +} + // lookup is an internal structure used to efficiently determine the layer in // which a state entry resides. type lookup struct {