mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-06-03 19:49:46 +02:00
in the last commits we had forgotten to handle the case in which there was no WithLabel().
This commit is contained in:
parent
05eb11e302
commit
fe3508881b
17
relay.go
17
relay.go
@ -409,18 +409,23 @@ func (r *Relay) PrepareSubscription(ctx context.Context, filters Filters, opts .
|
|||||||
match: filters.Match,
|
match: filters.Match,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
label := ""
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
switch o := opt.(type) {
|
switch o := opt.(type) {
|
||||||
case WithLabel:
|
case WithLabel:
|
||||||
buf := subIdPool.Get().([]byte)[:0]
|
label = string(o)
|
||||||
buf = strconv.AppendInt(buf, sub.counter, 10)
|
|
||||||
buf = append(buf, ':')
|
|
||||||
buf = append(buf, string(o)...)
|
|
||||||
defer subIdPool.Put(buf)
|
|
||||||
sub.id = string(buf)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// subscription id calculation
|
||||||
|
buf := subIdPool.Get().([]byte)[:0]
|
||||||
|
buf = strconv.AppendInt(buf, sub.counter, 10)
|
||||||
|
buf = append(buf, ':')
|
||||||
|
buf = append(buf, label...)
|
||||||
|
defer subIdPool.Put(buf)
|
||||||
|
sub.id = string(buf)
|
||||||
|
|
||||||
|
// we track subscriptions only by their counter, no need for the full id
|
||||||
r.Subscriptions.Store(int64(sub.counter), sub)
|
r.Subscriptions.Store(int64(sub.counter), sub)
|
||||||
|
|
||||||
// start handling events, eose, unsub etc:
|
// start handling events, eose, unsub etc:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user