From aaf7c423b43347367461a26658d8798e2ac5638a Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Thu, 28 Apr 2022 14:16:42 +0300 Subject: [PATCH] core: remove voter reward per committee properly (*Simple).Seek cuts search prefix, thus to remove voterRewardPerCommittee we need to append it again to the height value. May affect dumps. --- pkg/core/native/native_neo.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkg/core/native/native_neo.go b/pkg/core/native/native_neo.go index 715c7f140..8ded7a5d5 100644 --- a/pkg/core/native/native_neo.go +++ b/pkg/core/native/native_neo.go @@ -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