Skip to content

Commit

Permalink
pool.QuerySingle()
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Aug 6, 2023
1 parent b522d24 commit 5a51f84
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,13 @@ func (pool *SimplePool) SubManyEose(ctx context.Context, urls []string, filters

return uniqueEvents
}

// QuerySingle returns the first event returned by the first relay, cancels everything else.
func (pool *SimplePool) QuerySingle(ctx context.Context, urls []string, filter Filter) *Event {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
for evt := range pool.SubManyEose(ctx, urls, Filters{filter}) {
return evt
}
return nil
}

0 comments on commit 5a51f84

Please sign in to comment.