mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-07-03 20:17:04 +02:00
allocate subscription id only once on creation.
This commit is contained in:
8
relay.go
8
relay.go
@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@ -411,7 +412,12 @@ func (r *Relay) PrepareSubscription(ctx context.Context, filters Filters, opts .
|
||||
for _, opt := range opts {
|
||||
switch o := opt.(type) {
|
||||
case WithLabel:
|
||||
sub.label = string(o)
|
||||
buf := subIdPool.Get().([]byte)[:0]
|
||||
buf = strconv.AppendInt(buf, sub.counter, 10)
|
||||
buf = append(buf, ':')
|
||||
buf = append(buf, string(o)...)
|
||||
defer subIdPool.Put(buf)
|
||||
sub.id = string(buf)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user