forked from TrueCloudLab/frostfs-contract
[#196] nns: remove duplicate records in _deploy
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
d48709fcbb
commit
74e4bbb6b9
1 changed files with 28 additions and 40 deletions
|
@ -93,47 +93,35 @@ func _deploy(data interface{}, isUpdate bool) {
|
|||
args := data.([]interface{})
|
||||
common.CheckVersion(args[len(args)-1].(int))
|
||||
|
||||
if runtime.GetNetwork() == 0x572dfa5 {
|
||||
// Some of the domains in mainnet have duplicate SOA records.
|
||||
// One is stored by key with id 0, and the other with id []byte{0, 0, 0}.
|
||||
// Delete the latter. Subnet contract is not affected.
|
||||
ctx := storage.GetContext()
|
||||
committee := common.CommitteeAddress()
|
||||
it := storage.Find(ctx, []byte{prefixRoot}, storage.KeysOnly|storage.RemovePrefix)
|
||||
for iterator.Next(it) {
|
||||
name := iterator.Value(it).(string)
|
||||
if name != "neofs" {
|
||||
continue
|
||||
for _, name := range []string{
|
||||
"alphabet0.neofs",
|
||||
"alphabet1.neofs",
|
||||
"alphabet2.neofs",
|
||||
"alphabet3.neofs",
|
||||
"alphabet4.neofs",
|
||||
"alphabet5.neofs",
|
||||
"alphabet6.neofs",
|
||||
"container.neofs",
|
||||
"reputation.neofs",
|
||||
"neofsid.neofs",
|
||||
"balance.neofs",
|
||||
"netmap.neofs",
|
||||
"audit.neofs",
|
||||
} {
|
||||
tokenID := []byte(tokenIDFromName(name))
|
||||
recordsKey := getRecordsKeyByType(tokenID, name, SOA)
|
||||
oldKey := append(recordsKey, 0, 0, 0)
|
||||
data := storage.Get(ctx, oldKey)
|
||||
if data == nil {
|
||||
panic("unexpected")
|
||||
}
|
||||
|
||||
ns := NameState{
|
||||
Owner: committee,
|
||||
Name: name,
|
||||
Expiration: runtime.GetTime() + millisecondsInYear,
|
||||
storage.Delete(ctx, oldKey)
|
||||
}
|
||||
tokenKey := getTokenKey([]byte(name))
|
||||
putNameStateWithKey(ctx, tokenKey, ns)
|
||||
putSoaRecord(ctx, name, "ops@nspcc.ru",
|
||||
3600 /* 1 hour */, 600, /* 10 min */
|
||||
604800 /* 1 week */, 3600 /* 1 hour */)
|
||||
}
|
||||
|
||||
r := GetRecords("container.neofs", TXT)
|
||||
owner := shBEFromLEHex(r[0])
|
||||
|
||||
it = storage.Find(ctx, []byte{prefixRoot}, storage.KeysOnly|storage.RemovePrefix)
|
||||
for iterator.Next(it) {
|
||||
name := iterator.Value(it).(string)
|
||||
if name == "neofs" {
|
||||
continue
|
||||
}
|
||||
|
||||
ns := NameState{
|
||||
Owner: owner,
|
||||
Name: name,
|
||||
Expiration: runtime.GetTime() + millisecondsInYear,
|
||||
}
|
||||
tokenKey := getTokenKey([]byte(name))
|
||||
putNameStateWithKey(ctx, tokenKey, ns)
|
||||
putSoaRecord(ctx, name, "ops@nspcc.ru",
|
||||
3600 /* 1 hour */, 600, /* 10 min */
|
||||
604800 /* 1 week */, 3600 /* 1 hour */)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue