forked from TrueCloudLab/frostfs-contract
[#112] Remove to v0.9.2 migration code
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
9840f29372
commit
c7ed05cc2e
2 changed files with 0 additions and 50 deletions
|
@ -67,8 +67,6 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if isUpdate {
|
if isUpdate {
|
||||||
migrateContainerLists(ctx) // from v0.9.1 to v0.9.2
|
|
||||||
migrateEstimationStorage(ctx) // from v0.9.1 to v0.9.2
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,35 +100,6 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
runtime.Log("container contract initialized")
|
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 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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Migrate method updates contract source code and manifest. Can be invoked
|
// Migrate method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by contract owner.
|
||||||
func Migrate(script []byte, manifest []byte, data interface{}) bool {
|
func Migrate(script []byte, manifest []byte, data interface{}) bool {
|
||||||
|
|
|
@ -65,7 +65,6 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if isUpdate {
|
if isUpdate {
|
||||||
migrateNetmapCandidates(ctx) // from v0.9.1 to v0.9.2
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,24 +113,6 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
runtime.Log("netmap contract initialized")
|
runtime.Log("netmap contract initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
func migrateNetmapCandidates(ctx storage.Context) {
|
|
||||||
const netmapKey = "netmap"
|
|
||||||
|
|
||||||
data := storage.Get(ctx, netmapKey)
|
|
||||||
if data == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
candidates := std.Deserialize(data.([]byte)).([]netmapNode)
|
|
||||||
|
|
||||||
for i := range candidates {
|
|
||||||
candidate := candidates[i]
|
|
||||||
addToNetmap(ctx, candidate.node)
|
|
||||||
}
|
|
||||||
|
|
||||||
storage.Delete(ctx, netmapKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Migrate method updates contract source code and manifest. Can be invoked
|
// Migrate method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by contract owner.
|
||||||
func Migrate(script []byte, manifest []byte, data interface{}) bool {
|
func Migrate(script []byte, manifest []byte, data interface{}) bool {
|
||||||
|
|
Loading…
Reference in a new issue