Skip to content

Commit

Permalink
[#266] nns: Reuse storeRecord for storing SOA record
Browse files Browse the repository at this point in the history
Less code repeating.

Signed-off-by: Anna Shaleva <[email protected]>
  • Loading branch information
AnnaShaleva committed Sep 13, 2022
1 parent 9d34e45 commit 288369a
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions nns/nns_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,22 +596,14 @@ func storeRecord(ctx storage.Context, tokenId []byte, name string, typ RecordTyp

// putSoaRecord stores soa domain record.
func putSoaRecord(ctx storage.Context, name, email string, refresh, retry, expire, ttl int) {
var id byte
tokenId := []byte(tokenIDFromName(name))
recordKey := getIdRecordKey(tokenId, name, SOA, id)
rs := RecordState{
Name: name,
Type: SOA,
ID: id,
Data: name + " " + email + " " +
std.Itoa(runtime.GetTime(), 10) + " " +
std.Itoa(refresh, 10) + " " +
std.Itoa(retry, 10) + " " +
std.Itoa(expire, 10) + " " +
std.Itoa(ttl, 10),
}
recBytes := std.Serialize(rs)
storage.Put(ctx, recordKey, recBytes)
data := name + " " + email + " " +
std.Itoa(runtime.GetTime(), 10) + " " +
std.Itoa(refresh, 10) + " " +
std.Itoa(retry, 10) + " " +
std.Itoa(expire, 10) + " " +
std.Itoa(ttl, 10)
storeRecord(ctx, tokenId, name, SOA, 0, data)
}

// updateSoaSerial stores soa domain record.
Expand Down

0 comments on commit 288369a

Please sign in to comment.