make sub.Events a channel of pointers.

This commit is contained in:
fiatjaf 2023-01-26 09:04:27 -03:00
parent 0e2ee85785
commit 92c0143762
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1
2 changed files with 5 additions and 5 deletions

View File

@ -159,7 +159,7 @@ func (r *Relay) Connect(ctx context.Context) error {
if !subscription.Filters.Match(&event) || subscription.stopped {
return
}
subscription.Events <- event
subscription.Events <- &event
}()
}
case "EOSE":
@ -329,7 +329,7 @@ func (r *Relay) Subscribe(ctx context.Context, filters Filters) *Subscription {
return sub
}
func (r *Relay) QuerySync(ctx context.Context, filter Filter) []Event {
func (r *Relay) QuerySync(ctx context.Context, filter Filter) []*Event {
sub := r.Subscribe(ctx, Filters{filter})
defer sub.Unsub()
@ -340,7 +340,7 @@ func (r *Relay) QuerySync(ctx context.Context, filter Filter) []Event {
defer cancel()
}
var events []Event
var events []*Event
for {
select {
case evt := <-sub.Events:
@ -366,7 +366,7 @@ func (r *Relay) prepareSubscription(id string) *Subscription {
Relay: r,
conn: r.Connection,
id: id,
Events: make(chan Event),
Events: make(chan *Event),
EndOfStoredEvents: make(chan struct{}, 1),
}

View File

@ -12,7 +12,7 @@ type Subscription struct {
Relay *Relay
Filters Filters
Events chan Event
Events chan *Event
EndOfStoredEvents chan struct{}
stopped bool