nip61: perhaps simplify the function signature and support specific source mints.
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
package sdk
|
||||
|
||||
import (
|
||||
"slices"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
var json = jsoniter.ConfigFastest
|
||||
|
||||
// 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
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package sdk
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
|
||||
@@ -76,9 +76,9 @@ func (sys *System) FetchSpecificEvent(
|
||||
author = v.Author
|
||||
filter.IDs = []nostr.ID{v.ID}
|
||||
relays = append(relays, v.Relays...)
|
||||
relays = appendUnique(relays, sys.FallbackRelays.Next())
|
||||
relays = nostr.AppendUnique(relays, sys.FallbackRelays.Next())
|
||||
fallback = append(fallback, sys.JustIDRelays.URLs...)
|
||||
fallback = appendUnique(fallback, sys.FallbackRelays.Next())
|
||||
fallback = nostr.AppendUnique(fallback, sys.FallbackRelays.Next())
|
||||
priorityRelays = append(priorityRelays, v.Relays...)
|
||||
case nostr.EntityPointer:
|
||||
author = v.PublicKey
|
||||
@@ -86,7 +86,7 @@ func (sys *System) FetchSpecificEvent(
|
||||
filter.Tags = nostr.TagMap{"d": []string{v.Identifier}}
|
||||
filter.Kinds = []nostr.Kind{v.Kind}
|
||||
relays = append(relays, v.Relays...)
|
||||
relays = appendUnique(relays, sys.FallbackRelays.Next())
|
||||
relays = nostr.AppendUnique(relays, sys.FallbackRelays.Next())
|
||||
fallback = append(fallback, sys.FallbackRelays.Next(), sys.FallbackRelays.Next())
|
||||
priorityRelays = append(priorityRelays, v.Relays...)
|
||||
}
|
||||
@@ -110,8 +110,8 @@ func (sys *System) FetchSpecificEvent(
|
||||
}
|
||||
|
||||
// arrange these
|
||||
relays = appendUnique(relays, authorRelays...)
|
||||
priorityRelays = appendUnique(priorityRelays, authorRelays...)
|
||||
relays = nostr.AppendUnique(relays, authorRelays...)
|
||||
priorityRelays = nostr.AppendUnique(priorityRelays, authorRelays...)
|
||||
}
|
||||
|
||||
var result *nostr.Event
|
||||
|
||||
Reference in New Issue
Block a user