triedb/pathdb: polish code

This commit is contained in:
Gary Rong 2025-12-10 16:07:37 +08:00
parent 3c1443e525
commit c1729b7f52
3 changed files with 9 additions and 4 deletions

View file

@ -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 // If the layer is being generated, ensure the requested storage slot
// has already been covered by the generator. // has already been covered by the generator.
skey := storageKey(accountHash, storageHash) key := storageKeySlice(accountHash, storageHash)
key := skey[:]
marker := dl.genMarker() marker := dl.genMarker()
if marker != nil && bytes.Compare(key, marker) > 0 { if marker != nil && bytes.Compare(key, marker) > 0 {
return nil, errNotCoveredYet return nil, errNotCoveredYet

View file

@ -116,8 +116,7 @@ func writeStates(batch ethdb.Batch, genMarker []byte, accountData map[common.Has
continue continue
} }
slots += 1 slots += 1
skey := storageKey(addrHash, storageHash) key := storageKeySlice(addrHash, storageHash)
key := skey[:]
if len(blob) == 0 { if len(blob) == 0 {
rawdb.DeleteStorageSnapshot(batch, addrHash, storageHash) rawdb.DeleteStorageSnapshot(batch, addrHash, storageHash)
if clean != nil { if clean != nil {

View file

@ -33,6 +33,13 @@ func storageKey(accountHash common.Hash, slotHash common.Hash) [64]byte {
return key 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 // lookup is an internal structure used to efficiently determine the layer in
// which a state entry resides. // which a state entry resides.
type lookup struct { type lookup struct {