Merge pull request #2454 from nspcc-dev/fix-neo

core: remove voter reward per committee properly
This commit is contained in:
Roman Khimov 2022-04-28 23:36:32 +03:00 committed by GitHub
commit e2ae572a9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -585,15 +585,11 @@ func (n *NEO) dropCandidateIfZero(d *dao.Simple, pub *keys.PublicKey, c *candida
}
d.DeleteStorageItem(n.ID, makeValidatorKey(pub))
var toRemove []string
voterKey := makeVoterKey(pub.Bytes())
d.Seek(n.ID, storage.SeekRange{Prefix: voterKey}, func(k, v []byte) bool {
toRemove = append(toRemove, string(k))
d.DeleteStorageItem(n.ID, append(voterKey, k...)) // d.Seek cuts prefix, thus need to append it again.
return true
})
for i := range toRemove {
d.DeleteStorageItem(n.ID, []byte(toRemove[i]))
}
delete(n.gasPerVoteCache, string(voterKey))
return true, nil