mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 21:32:56 +01:00
make sub.Events a channel of pointers.
This commit is contained in:
parent
0e2ee85785
commit
92c0143762
8
relay.go
8
relay.go
@ -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),
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ type Subscription struct {
|
||||
|
||||
Relay *Relay
|
||||
Filters Filters
|
||||
Events chan Event
|
||||
Events chan *Event
|
||||
EndOfStoredEvents chan struct{}
|
||||
|
||||
stopped bool
|
||||
|
Loading…
x
Reference in New Issue
Block a user