[#102] nns: Support global domain
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
parent
49e5270f67
commit
b2eb585bb6
2 changed files with 30 additions and 1 deletions
|
@ -418,11 +418,15 @@ func GetRecords(name string, typ RecordType) []string {
|
|||
|
||||
// DeleteRecords removes domain records with the specified type.
|
||||
func DeleteRecords(name string, typ RecordType) {
|
||||
ctx := storage.GetContext()
|
||||
deleteRecords(ctx, name, typ)
|
||||
}
|
||||
|
||||
func deleteRecords(ctx storage.Context, name string, typ RecordType) {
|
||||
if typ == SOA {
|
||||
panic("you cannot delete soa record")
|
||||
}
|
||||
tokenID := []byte(tokenIDFromName(name))
|
||||
ctx := storage.GetContext()
|
||||
ns := getNameState(ctx, tokenID)
|
||||
ns.checkAdmin()
|
||||
recordsKey := getRecordsKeyByType(tokenID, name, typ)
|
||||
|
@ -434,6 +438,26 @@ func DeleteRecords(name string, typ RecordType) {
|
|||
updateSoaSerial(ctx, tokenID)
|
||||
}
|
||||
|
||||
// DeleteDomain deletes the domain with the given name.
|
||||
func DeleteDomain(name string) {
|
||||
ctx := storage.GetContext()
|
||||
deleteDomain(ctx, name)
|
||||
}
|
||||
|
||||
func deleteDomain(ctx storage.Context, name string) {
|
||||
nameKey := append([]byte{prefixName}, getTokenKey([]byte(name))...)
|
||||
tldBytes := storage.Get(ctx, nameKey)
|
||||
if tldBytes == nil {
|
||||
return
|
||||
}
|
||||
|
||||
deleteRecords(ctx, name, CNAME)
|
||||
deleteRecords(ctx, name, TXT)
|
||||
deleteRecords(ctx, name, A)
|
||||
deleteRecords(ctx, name, AAAA)
|
||||
storage.Delete(ctx, nameKey)
|
||||
}
|
||||
|
||||
// Resolve resolves given name (not more then three redirects are allowed).
|
||||
func Resolve(name string, typ RecordType) []string {
|
||||
ctx := storage.GetReadOnlyContext()
|
||||
|
|
|
@ -60,6 +60,11 @@ func New(actor Actor, hash util.Uint160) *Contract {
|
|||
return &Contract{ContractReader{nep11ndt.NonDivisibleReader, actor, hash}, nep11ndt.BaseWriter, actor, hash}
|
||||
}
|
||||
|
||||
// DeleteDomain invokes `deleteDomain` method of contract.
|
||||
func (c *ContractReader) DeleteDomain(name string) (*result.Invoke, error) {
|
||||
c.invoker.Call(c.hash, "deleteDomain", name)
|
||||
}
|
||||
|
||||
// GetPrice invokes `getPrice` method of contract.
|
||||
func (c *ContractReader) GetPrice() (*big.Int, error) {
|
||||
return unwrap.BigInt(c.invoker.Call(c.hash, "getPrice"))
|
||||
|
|
Loading…
Reference in a new issue