migrate to xsync/v3

closes https://github.com/nbd-wtf/go-nostr/issues/117
This commit is contained in:
fiatjaf 2024-01-10 06:54:52 -03:00
parent fd8b2b22b2
commit 7b292775c0
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1
4 changed files with 10 additions and 10 deletions

2
go.mod
View File

@ -8,7 +8,7 @@ require (
github.com/gobwas/httphead v0.1.0 github.com/gobwas/httphead v0.1.0
github.com/gobwas/ws v1.2.0 github.com/gobwas/ws v1.2.0
github.com/mailru/easyjson v0.7.7 github.com/mailru/easyjson v0.7.7
github.com/puzpuzpuz/xsync/v2 v2.5.1 github.com/puzpuzpuz/xsync/v3 v3.0.2
github.com/tidwall/gjson v1.14.4 github.com/tidwall/gjson v1.14.4
github.com/tyler-smith/go-bip32 v1.0.0 github.com/tyler-smith/go-bip32 v1.0.0
github.com/tyler-smith/go-bip39 v1.1.0 github.com/tyler-smith/go-bip39 v1.1.0

4
go.sum
View File

@ -79,8 +79,8 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/puzpuzpuz/xsync/v2 v2.5.1 h1:mVGYAvzDSu52+zaGyNjC+24Xw2bQi3kTr4QJ6N9pIIU= github.com/puzpuzpuz/xsync/v3 v3.0.2 h1:3yESHrRFYr6xzkz61LLkvNiPFXxJEAABanTQpKbAaew=
github.com/puzpuzpuz/xsync/v2 v2.5.1/go.mod h1:gD2H2krq/w52MfPLE+Uy64TzJDVY7lP2znR9qmR35kU= github.com/puzpuzpuz/xsync/v3 v3.0.2/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=

View File

@ -8,7 +8,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/puzpuzpuz/xsync/v2" "github.com/puzpuzpuz/xsync/v3"
) )
const ( const (
@ -37,7 +37,7 @@ func NewSimplePool(ctx context.Context, opts ...PoolOption) *SimplePool {
ctx, cancel := context.WithCancel(ctx) ctx, cancel := context.WithCancel(ctx)
pool := &SimplePool{ pool := &SimplePool{
Relays: xsync.NewMapOf[*Relay](), Relays: xsync.NewMapOf[string, *Relay](),
Context: ctx, Context: ctx,
cancel: cancel, cancel: cancel,
@ -100,7 +100,7 @@ func (pool *SimplePool) subMany(ctx context.Context, urls []string, filters Filt
ctx, cancel := context.WithCancel(ctx) ctx, cancel := context.WithCancel(ctx)
_ = cancel // do this so `go vet` will stop complaining _ = cancel // do this so `go vet` will stop complaining
events := make(chan IncomingEvent) events := make(chan IncomingEvent)
seenAlready := xsync.NewMapOf[Timestamp]() seenAlready := xsync.NewMapOf[string, Timestamp]()
ticker := time.NewTicker(seenAlreadyDropTick) ticker := time.NewTicker(seenAlreadyDropTick)
eose := false eose := false
@ -222,7 +222,7 @@ func (pool *SimplePool) subManyEose(ctx context.Context, urls []string, filters
ctx, cancel := context.WithCancel(ctx) ctx, cancel := context.WithCancel(ctx)
events := make(chan IncomingEvent) events := make(chan IncomingEvent)
seenAlready := xsync.NewMapOf[bool]() seenAlready := xsync.NewMapOf[string, bool]()
wg := sync.WaitGroup{} wg := sync.WaitGroup{}
wg.Add(len(urls)) wg.Add(len(urls))

View File

@ -12,7 +12,7 @@ import (
"github.com/gobwas/ws" "github.com/gobwas/ws"
"github.com/gobwas/ws/wsutil" "github.com/gobwas/ws/wsutil"
"github.com/puzpuzpuz/xsync/v2" "github.com/puzpuzpuz/xsync/v3"
) )
type Status int type Status int
@ -55,8 +55,8 @@ func NewRelay(ctx context.Context, url string, opts ...RelayOption) *Relay {
URL: NormalizeURL(url), URL: NormalizeURL(url),
connectionContext: ctx, connectionContext: ctx,
connectionContextCancel: cancel, connectionContextCancel: cancel,
Subscriptions: xsync.NewMapOf[*Subscription](), Subscriptions: xsync.NewMapOf[string, *Subscription](),
okCallbacks: xsync.NewMapOf[func(bool, string)](), okCallbacks: xsync.NewMapOf[string, func(bool, string)](),
writeQueue: make(chan writeRequest), writeQueue: make(chan writeRequest),
subscriptionChannelCloseQueue: make(chan *Subscription), subscriptionChannelCloseQueue: make(chan *Subscription),
} }