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
// 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

View file

@ -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 {

View file

@ -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 {