[#278] netmap: Migrate from the old storage format

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
support/v0.16
Evgenii Stratonikov 2022-09-30 17:38:37 +03:00 committed by fyrchik
parent 55ffc8f53c
commit c3b00e0011
1 changed files with 19 additions and 0 deletions

View File

@ -94,6 +94,25 @@ func _deploy(data interface{}, isUpdate bool) {
if isUpdate {
common.CheckVersion(args.version)
count := getSnapshotCount(ctx)
prefix := []byte(snapshotKeyPrefix)
for i := 0; i < count; i++ {
key := append(prefix, byte(i))
data := storage.Get(ctx, key)
if data != nil {
nodes := std.Deserialize(data.([]byte)).([]Node)
for i := range nodes {
// Old structure contains only the first field,
// second is implicitly assumed to be Online.
nodes[i] = Node{
BLOB: nodes[i].BLOB,
State: NodeStateOnline,
}
}
common.SetSerialized(ctx, key, nodes)
}
}
return
}