From 820bd283c1d8b4e4c8407f83228e6a8248e2a7b7 Mon Sep 17 00:00:00 2001 From: Alexander Chuprov Date: Mon, 23 Sep 2024 13:25:42 +0300 Subject: [PATCH] [#114] nns: Move deleting global aliases along with TXT records Signed-off-by: Alexander Chuprov --- nns/nns_contract.go | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/nns/nns_contract.go b/nns/nns_contract.go index 197ddfc..a76aaf0 100644 --- a/nns/nns_contract.go +++ b/nns/nns_contract.go @@ -509,12 +509,16 @@ func deleteRecords(ctx storage.Context, name string, typ RecordType) { tokenID := []byte(tokenIDFromName(name)) ns := getNameState(ctx, tokenID) ns.checkAdmin() - - globalDomainStorage := append([]byte{prefixGlobalDomain}, getTokenKey([]byte(name))...) - globalDomainRaw := storage.Get(ctx, globalDomainStorage) - globalDomain := globalDomainRaw.(string) - if globalDomainRaw != nil && globalDomain != "" { - deleteDomain(ctx, globalDomain) + if typ == TXT { + globalDomainKey := append([]byte{prefixGlobalDomain}, getTokenKey([]byte(name))...) + globalDomainRaw := storage.Get(ctx, globalDomainKey) + if globalDomainRaw != nil { + globalDomain := globalDomainRaw.(string) + if globalDomain != "" { + deleteDomain(ctx, globalDomain) + } + storage.Delete(ctx, globalDomainKey) + } } recordsKey := getRecordsKeyByType(tokenID, name, typ) @@ -550,13 +554,6 @@ func deleteDomain(ctx storage.Context, name string) { ns := std.Deserialize(nsRaw.([]byte)).(NameState) ns.checkAdmin() - globalNSKey := append([]byte{prefixGlobalDomain}, getTokenKey([]byte(name))...) - globalDomainRaw := storage.Get(ctx, globalNSKey) - globalDomain := globalDomainRaw.(string) - if globalDomainRaw != nil && globalDomain != "" { - deleteDomain(ctx, globalDomain) - } - deleteRecords(ctx, name, CNAME) deleteRecords(ctx, name, TXT) deleteRecords(ctx, name, A)