fix atomicity of subscription ids.

This commit is contained in:
fiatjaf
2023-06-09 11:01:42 -03:00
parent b7ec430166
commit bc783a3a24
2 changed files with 6 additions and 7 deletions

View File

@@ -9,7 +9,7 @@ import (
type Subscription struct {
label string
counter int64
counter int
conn *Connection
mutex sync.Mutex
@@ -38,7 +38,7 @@ func (sub *Subscription) SetLabel(label string) {
// GetID return the Nostr subscription ID as given to the relay, it will be a sequential number, stringified.
func (sub *Subscription) GetID() string {
return sub.label + ":" + strconv.FormatInt(sub.counter, 10)
return sub.label + ":" + strconv.Itoa(sub.counter)
}
// Unsub closes the subscription, sending "CLOSE" to relay as in NIP-01.