nip61: perhaps simplify the function signature and support specific source mints.

This commit is contained in:
fiatjaf
2025-05-05 16:56:20 -03:00
parent b711548b03
commit 3723924561
5 changed files with 50 additions and 42 deletions

View File

@@ -5,6 +5,7 @@ import (
"cmp"
"encoding/hex"
"net/url"
"slices"
)
// IsValidRelayURL checks if a URL is a valid relay URL (ws:// or wss://).
@@ -46,3 +47,15 @@ func CompareEventReverse(b, a Event) int {
}
return cmp.Compare(a.CreatedAt, b.CreatedAt)
}
// AppendUnique adds items to an array only if they don't already exist in the array.
// Returns the modified array.
func AppendUnique[I comparable](arr []I, item ...I) []I {
for _, item := range item {
if slices.Contains(arr, item) {
return arr
}
arr = append(arr, item)
}
return arr
}