Skip to content

Commit

Permalink
[nspcc-dev#266] nns: Move common code to a separate method
Browse files Browse the repository at this point in the history
Reuse getAllRecords for GetAllRecords.

Signed-off-by: Anna Shaleva <[email protected]>
  • Loading branch information
AnnaShaleva committed Sep 13, 2022
1 parent 0606349 commit d3d4a81
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions nns/nns_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,8 @@ func Resolve(name string, typ RecordType) []string {

// GetAllRecords returns an Iterator with RecordState items for the given name.
func GetAllRecords(name string) iterator.Iterator {
tokenID := []byte(tokenIDFromName(name))
ctx := storage.GetReadOnlyContext()
_ = getNameState(ctx, tokenID) // ensure not expired
recordsKey := getRecordsKey(tokenID, name)
return storage.Find(ctx, recordsKey, storage.ValuesOnly|storage.DeserializeValues)
return getAllRecords(ctx, name)
}

// updateBalance updates account's balance and account's tokens.
Expand Down Expand Up @@ -913,7 +910,7 @@ func resolve(ctx storage.Context, res []string, name string, typ RecordType, red
// specified name.
func getAllRecords(ctx storage.Context, name string) iterator.Iterator {
tokenID := []byte(tokenIDFromName(name))
_ = getNameState(ctx, tokenID)
_ = getNameState(ctx, tokenID) // ensure not expired.
recordsKey := getRecordsKey(tokenID, name)
return storage.Find(ctx, recordsKey, storage.ValuesOnly|storage.DeserializeValues)
}

0 comments on commit d3d4a81

Please sign in to comment.