WithCheckDuplicate(), let's see if this works.

This commit is contained in:
fiatjaf
2025-01-15 14:26:00 -03:00
parent ba38c28b99
commit e1971d12c0
4 changed files with 21 additions and 36 deletions

View File

@@ -33,7 +33,7 @@ type Subscription struct {
// if it is not nil, CheckDuplicate will be called for every event received
// if it returns true that event will not be processed further.
CheckDuplicate func(id string, relay string) bool
checkDuplicate func(id string, relay string) bool
match func(*Event) bool // this will be either Filters.Match or Filters.MatchIgnoringTimestampConstraints
live atomic.Bool
@@ -62,7 +62,15 @@ type WithLabel string
func (_ WithLabel) IsSubscriptionOption() {}
var _ SubscriptionOption = (WithLabel)("")
// WithCheckDuplicate sets checkDuplicate on the subscription
type WithCheckDuplicate func(relay, id string) bool
func (_ WithCheckDuplicate) IsSubscriptionOption() {}
var (
_ SubscriptionOption = (WithLabel)("")
_ SubscriptionOption = (WithCheckDuplicate)(nil)
)
func (sub *Subscription) start() {
<-sub.Context.Done()