core/state/snapshot: fix various iteration issues due to destruct set

This commit is contained in:
Péter Szilágyi
2020-03-04 15:06:04 +02:00
parent bc5d742c66
commit fab0ee3bfa
4 changed files with 67 additions and 39 deletions

View File

@ -60,12 +60,6 @@ type diffAccountIterator struct {
// hash as long as the iterator is not touched any more.
curHash common.Hash
// curAccount is the current value the iterator is positioned on. The field
// is explicitly tracked since the referenced diff layer might go stale after
// the iterator was positioned and we don't want to fail accessing the old
// value as long as the iterator is not touched any more.
//curAccount []byte
layer *diffLayer // Live layer to retrieve values from
keys []common.Hash // Keys left in the layer to iterate
fail error // Any failures encountered (stale)
@ -130,6 +124,9 @@ func (it *diffAccountIterator) Account() []byte {
it.layer.lock.RLock()
blob, ok := it.layer.accountData[it.curHash]
if !ok {
if _, ok := it.layer.destructSet[it.curHash]; ok {
return nil
}
panic(fmt.Sprintf("iterator referenced non-existent account: %x", it.curHash))
}
it.layer.lock.RUnlock()