mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-11-19 18:47:37 +01:00
remove unnecessary mutex.
This commit is contained in:
5
pool.go
5
pool.go
@@ -103,7 +103,6 @@ func (pool *SimplePool) subMany(ctx context.Context, urls []string, filters Filt
|
|||||||
seenAlready := xsync.NewMapOf[Timestamp]()
|
seenAlready := xsync.NewMapOf[Timestamp]()
|
||||||
ticker := time.NewTicker(seenAlreadyDropTick)
|
ticker := time.NewTicker(seenAlreadyDropTick)
|
||||||
|
|
||||||
var mu sync.Mutex
|
|
||||||
eose := false
|
eose := false
|
||||||
|
|
||||||
pending := xsync.NewCounter()
|
pending := xsync.NewCounter()
|
||||||
@@ -143,9 +142,7 @@ func (pool *SimplePool) subMany(ctx context.Context, urls []string, filters Filt
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
<-sub.EndOfStoredEvents
|
<-sub.EndOfStoredEvents
|
||||||
mu.Lock()
|
|
||||||
eose = true
|
eose = true
|
||||||
mu.Unlock()
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// reset interval when we get a good subscription
|
// reset interval when we get a good subscription
|
||||||
@@ -174,7 +171,6 @@ func (pool *SimplePool) subMany(ctx context.Context, urls []string, filters Filt
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
}
|
}
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
mu.Lock()
|
|
||||||
if eose {
|
if eose {
|
||||||
old := Timestamp(time.Now().Add(-seenAlreadyDropTick).Unix())
|
old := Timestamp(time.Now().Add(-seenAlreadyDropTick).Unix())
|
||||||
seenAlready.Range(func(id string, value Timestamp) bool {
|
seenAlready.Range(func(id string, value Timestamp) bool {
|
||||||
@@ -184,7 +180,6 @@ func (pool *SimplePool) subMany(ctx context.Context, urls []string, filters Filt
|
|||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
mu.Unlock()
|
|
||||||
case reason := <-sub.ClosedReason:
|
case reason := <-sub.ClosedReason:
|
||||||
if strings.HasPrefix(reason, "auth-required:") && pool.authHandler != nil && !hasAuthed {
|
if strings.HasPrefix(reason, "auth-required:") && pool.authHandler != nil && !hasAuthed {
|
||||||
// relay is requesting auth. if we can we will perform auth and try again
|
// relay is requesting auth. if we can we will perform auth and try again
|
||||||
|
|||||||
Reference in New Issue
Block a user