Skip to content

Commit

Permalink
[#278] netmap: Migrate from the old storage format
Browse files Browse the repository at this point in the history
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
  • Loading branch information
fyrchik committed Oct 17, 2022
1 parent 55ffc8f commit c3b00e0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions netmap/netmap_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit c3b00e0

Please sign in to comment.