[#215] container: remove old estimations without intermediate array

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
support/v0.16
Evgenii Stratonikov 2022-01-17 12:36:56 +03:00 committed by Alex Vanin
parent 413a7eabfe
commit 72da098876
1 changed files with 3 additions and 10 deletions

View File

@ -577,10 +577,7 @@ func NewEpoch(epochNum int) {
common.CheckAlphabetWitness(multiaddr) common.CheckAlphabetWitness(multiaddr)
} }
candidates := keysToDelete(ctx, epochNum) cleanupContainers(ctx, epochNum)
for _, candidate := range candidates {
storage.Delete(ctx, candidate)
}
} }
// StartContainerEstimation method produces StartEstimation notification. // StartContainerEstimation method produces StartEstimation notification.
@ -774,9 +771,7 @@ func isStorageNode(ctx storage.Context, key interop.PublicKey) bool {
return false return false
} }
func keysToDelete(ctx storage.Context, epoch int) [][]byte { func cleanupContainers(ctx storage.Context, epoch int) {
results := [][]byte{}
it := storage.Find(ctx, []byte(estimateKeyPrefix), storage.KeysOnly) it := storage.Find(ctx, []byte(estimateKeyPrefix), storage.KeysOnly)
for iterator.Next(it) { for iterator.Next(it) {
k := iterator.Value(it).([]byte) k := iterator.Value(it).([]byte)
@ -786,9 +781,7 @@ func keysToDelete(ctx storage.Context, epoch int) [][]byte {
var n interface{} = nbytes var n interface{} = nbytes
if epoch-n.(int) > cleanupDelta { if epoch-n.(int) > cleanupDelta {
results = append(results, k) storage.Delete(ctx, k)
} }
} }
return results
} }