triedb/pathdb: use copy instead of append to reduce memory alloc

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
jsvisa 2025-10-29 03:17:15 +00:00
parent 739f6f46a2
commit 3c1443e525
2 changed files with 6 additions and 3 deletions

View file

@ -275,7 +275,8 @@ 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.
key := append(accountHash[:], storageHash[:]...)
skey := storageKey(accountHash, storageHash)
key := skey[:]
marker := dl.genMarker()
if marker != nil && bytes.Compare(key, marker) > 0 {
return nil, errNotCoveredYet

View file

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