mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-11-19 02:26:34 +01:00
WithCheckDuplicate(), let's see if this works.
This commit is contained in:
14
pool.go
14
pool.go
@@ -287,15 +287,14 @@ func (pool *SimplePool) SubMany(
|
||||
hasAuthed = false
|
||||
|
||||
subscribe:
|
||||
sub = relay.PrepareSubscription(ctx, filters, opts...)
|
||||
sub.CheckDuplicate = func(id, relay string) bool {
|
||||
sub, err = relay.Subscribe(ctx, filters, append(opts, WithCheckDuplicate(func(relay, id string) bool {
|
||||
_, exists := seenAlready.Load(id)
|
||||
if exists && pool.duplicateMiddleware != nil {
|
||||
pool.duplicateMiddleware(relay, id)
|
||||
}
|
||||
return exists
|
||||
}
|
||||
if err := sub.Fire(); err != nil {
|
||||
}))...)
|
||||
if err != nil {
|
||||
goto reconnect
|
||||
}
|
||||
|
||||
@@ -418,15 +417,14 @@ func (pool *SimplePool) SubManyEose(
|
||||
hasAuthed := false
|
||||
|
||||
subscribe:
|
||||
sub := relay.PrepareSubscription(ctx, filters, opts...)
|
||||
sub.CheckDuplicate = func(id, relay string) bool {
|
||||
sub, err := relay.Subscribe(ctx, filters, append(opts, WithCheckDuplicate(func(relay, id string) bool {
|
||||
_, exists := seenAlready.Load(id)
|
||||
if exists && pool.duplicateMiddleware != nil {
|
||||
pool.duplicateMiddleware(relay, id)
|
||||
}
|
||||
return exists
|
||||
}
|
||||
if err := sub.Fire(); err != nil {
|
||||
}))...)
|
||||
if err != nil {
|
||||
debugLogf("error subscribing to %s with %v: %s", relay, filters, err)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user