Skip to content

Commit

Permalink
Fixed some linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kpachhai committed Oct 8, 2024
1 parent 147dce1 commit 131db44
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
6 changes: 4 additions & 2 deletions actions/complete_contribute_dataset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ import (
)

func TestCompleteContributeDatasetAction(t *testing.T) {
dataLocation := "default"
dataIdentifier := "data_id_1234"
const (
dataLocation = "default"
dataIdentifier = "data_id_1234"
)

actor := codectest.NewRandomAddress()
datasetAddress := storage.AssetAddress(nconsts.AssetFractionalTokenID, []byte("Valid Name"), []byte("DATASET"), 0, []byte("metadata"), actor)
Expand Down
2 changes: 1 addition & 1 deletion actions/initiate_contribute_dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (d *InitiateContributeDataset) Execute(
}

// Check if the data location is valid
dataLocation := "default"
dataLocation := storage.DatasetDefaultLocation
if len(d.DataLocation) > 0 {
dataLocation = d.DataLocation
}
Expand Down
4 changes: 4 additions & 0 deletions storage/dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const (
MaxDatasetDataLocationSize = 64
)

const (
DatasetDefaultLocation = "default"
)

func DatasetInfoKey(datasetAddress codec.Address) (k []byte) {
k = make([]byte, 1+codec.AddressLen+consts.Uint16Len) // Length of prefix + datasetAddress + DatasetInfoChunks
k[0] = datasetInfoPrefix // datasetInfoPrefix is a constant representing the dataset category
Expand Down
10 changes: 5 additions & 5 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func FormatBalance(bal uint64, decimals uint8) string {
return strconv.FormatFloat(float64(bal)/math.Pow10(int(decimals)), 'f', int(decimals), 64)
}

func CombineWithSuffix(name []byte, uniqueNum uint64, maxLength int) []byte {
func CombineWithSuffix(field []byte, uniqueNum uint64, maxLength int) []byte {
// Convert the unique number to a string and append a hyphen
uniqueNumStr := fmt.Sprintf("-%d", uniqueNum)
uniqueNumLen := len(uniqueNumStr)
Expand All @@ -36,12 +36,12 @@ func CombineWithSuffix(name []byte, uniqueNum uint64, maxLength int) []byte {
maxNameLen := maxLength - uniqueNumLen

// Truncate the name if it's too long to fit with the suffix
if len(name) > maxNameLen {
name = name[:maxNameLen]
if len(field) > maxNameLen {
field = field[:maxNameLen]
}

// Combine the truncated name with the suffix
result := append(name, []byte(uniqueNumStr)...)
field = append(field, []byte(uniqueNumStr)...)

return result
return field
}

0 comments on commit 131db44

Please sign in to comment.