Skip to content

Commit

Permalink
triedb/pathdb: address comment from martin
Browse files Browse the repository at this point in the history
  • Loading branch information
rjl493456442 committed Oct 23, 2024
1 parent 2074ea8 commit 7169f52
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions triedb/pathdb/disklayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,21 @@ func (dl *diskLayer) revert(h *history) (*diskLayer, error) {
}
var (
buff = crypto.NewKeccakState()
hashes = make(map[common.Address]common.Hash)
accounts = make(map[common.Hash][]byte)
storages = make(map[common.Hash]map[common.Hash][]byte)
)
for addr, blob := range h.accounts {
accounts[crypto.HashData(buff, addr.Bytes())] = blob
hash := crypto.HashData(buff, addr.Bytes())
hashes[addr] = hash
accounts[hash] = blob
}
for addr, storage := range h.storages {
storages[crypto.HashData(buff, addr.Bytes())] = storage
hash, ok := hashes[addr]
if !ok {
panic(fmt.Errorf("storage history with no account %x", addr))
}
storages[hash] = storage
}
// Apply the reverse state changes upon the current state. This must
// be done before holding the lock in order to access state in "this"
Expand Down

0 comments on commit 7169f52

Please sign in to comment.