mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
some upgrades relate to pathdb
This commit is contained in:
parent
263aef9cc4
commit
3a25fea6da
2 changed files with 20 additions and 32 deletions
|
|
@ -1052,9 +1052,9 @@ func (s *StateDB) deleteStorage(addr common.Address, addrHash common.Hash, root
|
|||
// with their values be tracked as original value.
|
||||
func (s *StateDB) handleDestruction(noStorageWiping bool) (map[common.Hash]*accountDelete, []*trienode.NodeSet, error) {
|
||||
var (
|
||||
nodes []*trienode.NodeSet
|
||||
buf = crypto.NewKeccakState()
|
||||
deletes = make(map[common.Hash]*accountDelete)
|
||||
nodes = make([]*trienode.NodeSet, 0, len(s.stateObjectsDestruct))
|
||||
hasher = crypto.NewKeccakState()
|
||||
deletes = make(map[common.Hash]*accountDelete, len(s.stateObjectsDestruct))
|
||||
)
|
||||
for addr, prevObj := range s.stateObjectsDestruct {
|
||||
prev := prevObj.origin
|
||||
|
|
@ -1063,12 +1063,12 @@ func (s *StateDB) handleDestruction(noStorageWiping bool) (map[common.Hash]*acco
|
|||
// of block. It can be either case (a) or (b) and will be interpreted as
|
||||
// null->null state transition.
|
||||
// - for (a), skip it without doing anything
|
||||
// - for (b), the resurrected account with nil as original will be handled afterwards
|
||||
// - for (b), the resurrected account with nil as original will be handled afterward
|
||||
if prev == nil {
|
||||
continue
|
||||
}
|
||||
// The account was existent, it can be either case (c) or (d).
|
||||
addrHash := crypto.HashData(buf, addr.Bytes())
|
||||
addrHash := crypto.HashData(hasher, addr.Bytes())
|
||||
op := &accountDelete{
|
||||
address: addr,
|
||||
origin: types.SlimAccountRLP(*prev),
|
||||
|
|
|
|||
|
|
@ -338,12 +338,10 @@ func (s *stateSet) encode(w io.Writer) error {
|
|||
AddrHashes []common.Hash
|
||||
Accounts [][]byte
|
||||
}
|
||||
var enc accounts
|
||||
for addrHash, blob := range s.accountData {
|
||||
enc.AddrHashes = append(enc.AddrHashes, addrHash)
|
||||
enc.Accounts = append(enc.Accounts, blob)
|
||||
}
|
||||
if err := rlp.Encode(w, enc); err != nil {
|
||||
if err := rlp.Encode(w, accounts{
|
||||
AddrHashes: slices.Collect(maps.Keys(s.accountData)),
|
||||
Accounts: slices.Collect(maps.Values(s.accountData)),
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
// Encode storages
|
||||
|
|
@ -354,16 +352,10 @@ func (s *stateSet) encode(w io.Writer) error {
|
|||
}
|
||||
storages := make([]Storage, 0, len(s.storageData))
|
||||
for addrHash, slots := range s.storageData {
|
||||
keys := make([]common.Hash, 0, len(slots))
|
||||
vals := make([][]byte, 0, len(slots))
|
||||
for key, val := range slots {
|
||||
keys = append(keys, key)
|
||||
vals = append(vals, val)
|
||||
}
|
||||
storages = append(storages, Storage{
|
||||
AddrHash: addrHash,
|
||||
Keys: keys,
|
||||
Vals: vals,
|
||||
Keys: slices.Collect(maps.Keys(slots)),
|
||||
Vals: slices.Collect(maps.Values(slots)),
|
||||
})
|
||||
}
|
||||
return rlp.Encode(w, storages)
|
||||
|
|
@ -498,12 +490,10 @@ func (s *StateSetWithOrigin) encode(w io.Writer) error {
|
|||
Addresses []common.Address
|
||||
Accounts [][]byte
|
||||
}
|
||||
var accounts Accounts
|
||||
for address, blob := range s.accountOrigin {
|
||||
accounts.Addresses = append(accounts.Addresses, address)
|
||||
accounts.Accounts = append(accounts.Accounts, blob)
|
||||
}
|
||||
if err := rlp.Encode(w, accounts); err != nil {
|
||||
if err := rlp.Encode(w, Accounts{
|
||||
Addresses: slices.Collect(maps.Keys(s.accountOrigin)),
|
||||
Accounts: slices.Collect(maps.Values(s.accountOrigin)),
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
// Encode storages
|
||||
|
|
@ -514,13 +504,11 @@ func (s *StateSetWithOrigin) encode(w io.Writer) error {
|
|||
}
|
||||
storages := make([]Storage, 0, len(s.storageOrigin))
|
||||
for address, slots := range s.storageOrigin {
|
||||
keys := make([]common.Hash, 0, len(slots))
|
||||
vals := make([][]byte, 0, len(slots))
|
||||
for key, val := range slots {
|
||||
keys = append(keys, key)
|
||||
vals = append(vals, val)
|
||||
}
|
||||
storages = append(storages, Storage{Address: address, Keys: keys, Vals: vals})
|
||||
storages = append(storages, Storage{
|
||||
Address: address,
|
||||
Keys: slices.Collect(maps.Keys(slots)),
|
||||
Vals: slices.Collect(maps.Values(slots)),
|
||||
})
|
||||
}
|
||||
return rlp.Encode(w, storages)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue