From 12889ac87ef90709f2a7ad36d5d3ff54022a766e Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 30 Jun 2021 19:09:10 +0300 Subject: [PATCH] [#102] container: Migrate container estimation storage Signed-off-by: Alex Vanin --- container/container_contract.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/container/container_contract.go b/container/container_contract.go index 11fb7e9..dc84387 100644 --- a/container/container_contract.go +++ b/container/container_contract.go @@ -67,7 +67,8 @@ func _deploy(data interface{}, isUpdate bool) { ctx := storage.GetContext() if isUpdate { - migrateContainerLists(ctx) // from v0.9.1 to v0.9.2 + migrateContainerLists(ctx) // from v0.9.1 to v0.9.2 + migrateEstimationStorage(ctx) // from v0.9.1 to v0.9.2 return } @@ -118,6 +119,18 @@ func migrateContainerLists(ctx storage.Context) { storage.Delete(ctx, ownersKey) } +func migrateEstimationStorage(ctx storage.Context) { + // In fact, this method does not migrate estimation storage because this data + // is valid only for one epoch. Migration routine will be quite complex, so + // it makes sense to clean all remaining estimations and wait for new one. + + it := storage.Find(ctx, []byte(estimateKeyPrefix), storage.KeysOnly) + for iterator.Next(it) { + key := iterator.Value(it).([]byte) + storage.Delete(ctx, key) + } +} + func Migrate(script []byte, manifest []byte, data interface{}) bool { ctx := storage.GetReadOnlyContext()