mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
triedb/pathdb: address comment from martin
This commit is contained in:
parent
0a8af7177a
commit
1c84b6ccaf
1 changed files with 9 additions and 2 deletions
|
|
@ -297,14 +297,21 @@ func (dl *diskLayer) revert(h *history) (*diskLayer, error) {
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
buff = crypto.NewKeccakState()
|
buff = crypto.NewKeccakState()
|
||||||
|
hashes = make(map[common.Address]common.Hash)
|
||||||
accounts = make(map[common.Hash][]byte)
|
accounts = make(map[common.Hash][]byte)
|
||||||
storages = make(map[common.Hash]map[common.Hash][]byte)
|
storages = make(map[common.Hash]map[common.Hash][]byte)
|
||||||
)
|
)
|
||||||
for addr, blob := range h.accounts {
|
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 {
|
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
|
// Apply the reverse state changes upon the current state. This must
|
||||||
// be done before holding the lock in order to access state in "this"
|
// be done before holding the lock in order to access state in "this"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue