mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-08-03 00:12:17 +02:00
WithCheckDuplicateReplaceable() and helper functions for efficient replaceable event matching.
This commit is contained in:
@@ -33,10 +33,14 @@ type Subscription struct {
|
||||
// Context will be .Done() when the subscription ends
|
||||
Context context.Context
|
||||
|
||||
// if it is not nil, CheckDuplicate will be called for every event received
|
||||
// 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
|
||||
|
||||
// if it is not nil, checkDuplicateReplaceable will be called for every event received
|
||||
// if it returns true that event will not be processed further.
|
||||
checkDuplicateReplaceable func(d string, ts Timestamp) bool
|
||||
|
||||
match func(*Event) bool // this will be either Filters.Match or Filters.MatchIgnoringTimestampConstraints
|
||||
live atomic.Bool
|
||||
eosed atomic.Bool
|
||||
@@ -63,9 +67,15 @@ type WithCheckDuplicate func(id, relay string) bool
|
||||
|
||||
func (_ WithCheckDuplicate) IsSubscriptionOption() {}
|
||||
|
||||
// WithCheckDuplicateReplaceable sets checkDuplicateReplaceable on the subscription
|
||||
type WithCheckDuplicateReplaceable func(d string, ts Timestamp) bool
|
||||
|
||||
func (_ WithCheckDuplicateReplaceable) IsSubscriptionOption() {}
|
||||
|
||||
var (
|
||||
_ SubscriptionOption = (WithLabel)("")
|
||||
_ SubscriptionOption = (WithCheckDuplicate)(nil)
|
||||
_ SubscriptionOption = (WithCheckDuplicateReplaceable)(nil)
|
||||
)
|
||||
|
||||
func (sub *Subscription) start() {
|
||||
|
Reference in New Issue
Block a user