[#102] container: Migrate container listing storage

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
enable-notary-in-public-chains
Alex Vanin 2021-06-30 17:09:59 +03:00 committed by Alex Vanin
parent 98c5fd25c3
commit 2402768eae
1 changed files with 18 additions and 0 deletions

View File

@ -66,6 +66,7 @@ func _deploy(data interface{}, isUpdate bool) {
ctx := storage.GetContext()
if isUpdate {
migrateContainerLists(ctx) // from v0.9.1 to v0.9.2
return
}
@ -99,6 +100,23 @@ func _deploy(data interface{}, isUpdate bool) {
runtime.Log("container contract initialized")
}
func migrateContainerLists(ctx storage.Context) {
const ownersKey = "ownersList"
containers := getAllContainers(ctx)
for i := range containers {
containerID := containers[i]
ownerID := getOwnerByID(ctx, containerID)
containerListKey := append(ownerID, containerID...)
storage.Put(ctx, containerListKey, containerID)
storage.Delete(ctx, ownerID)
}
storage.Delete(ctx, ownersKey)
}
func Migrate(script []byte, manifest []byte, data interface{}) bool {
ctx := storage.GetReadOnlyContext()