Skip to content

Commit

Permalink
[#266] nns: Accept token ID as an argument for storeRecord
Browse files Browse the repository at this point in the history
It doesn't save VM opcodes, but allows to keep record key creation
logic in a single place which prevents the code from bugs appearance.

Signed-off-by: Anna Shaleva <[email protected]>
  • Loading branch information
AnnaShaleva committed Sep 13, 2022
1 parent d7b7a98 commit 9d34e45
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nns/nns_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ func SetRecord(name string, typ RecordType, id byte, data string) {
if recBytes == nil {
panic("invalid record id")
}
storeRecord(ctx, recordKey, name, typ, id, data)
storeRecord(ctx, tokenId, name, typ, id, data)
updateSoaSerial(ctx, tokenId)
}

Expand Down Expand Up @@ -436,8 +436,7 @@ func AddRecord(name string, typ RecordType, data string) {
panic("you shouldn't have more than one CNAME record")
}

recordKey := append(recordsKey, id) // the same as getIdRecordKey
storeRecord(ctx, recordKey, name, typ, id, data)
storeRecord(ctx, tokenId, name, typ, id, data)
updateSoaSerial(ctx, tokenId)
}

Expand Down Expand Up @@ -583,7 +582,8 @@ func getRecordsByType(ctx storage.Context, tokenId []byte, name string, typ Reco
}

// storeRecord puts record to storage and performs no additional checks.
func storeRecord(ctx storage.Context, recordKey []byte, name string, typ RecordType, id byte, data string) {
func storeRecord(ctx storage.Context, tokenId []byte, name string, typ RecordType, id byte, data string) {
recordKey := getIdRecordKey(tokenId, name, typ, id)
rs := RecordState{
Name: name,
Type: typ,
Expand Down

0 comments on commit 9d34e45

Please sign in to comment.