mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
triedb/pathdb: use copy instead of append to reduce memory alloc
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
739f6f46a2
commit
3c1443e525
2 changed files with 6 additions and 3 deletions
|
|
@ -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
|
// 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.
|
||||||
key := append(accountHash[:], storageHash[:]...)
|
skey := storageKey(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
|
||||||
|
|
|
||||||
|
|
@ -116,15 +116,17 @@ func writeStates(batch ethdb.Batch, genMarker []byte, accountData map[common.Has
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
slots += 1
|
slots += 1
|
||||||
|
skey := storageKey(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 {
|
||||||
clean.Set(append(addrHash[:], storageHash[:]...), nil)
|
clean.Set(key, nil)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rawdb.WriteStorageSnapshot(batch, addrHash, storageHash, blob)
|
rawdb.WriteStorageSnapshot(batch, addrHash, storageHash, blob)
|
||||||
if clean != nil {
|
if clean != nil {
|
||||||
clean.Set(append(addrHash[:], storageHash[:]...), blob)
|
clean.Set(key, blob)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue