From 13813b502a8d94f116cb24ef0a682ed3602fc564 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Thu, 21 May 2026 17:32:32 -0300 Subject: [PATCH] nip46: another client fix in the magic guarding of successfulness. --- nip46/client.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/nip46/client.go b/nip46/client.go index 68afdc2..647a51a 100644 --- a/nip46/client.go +++ b/nip46/client.go @@ -6,6 +6,7 @@ import ( "math/rand" "net/url" "strconv" + "sync" "sync/atomic" "time" "unsafe" @@ -309,19 +310,21 @@ func (bunker *BunkerClient) RPC(ctx context.Context, method string, params []str bunker.listeners.Store(id, dispatcher) defer bunker.listeners.Delete(id) relayConnectionWorked := make(chan struct{}) + relayConnectionWorkedO := sync.OnceFunc(func() { + close(relayConnectionWorked) + }) bunkerConnectionWorked := make(chan struct{}) + bunkerConnectionWorkedO := sync.OnceFunc(func() { + close(bunkerConnectionWorked) + }) for _, url := range bunker.Relays { go func(url string) { relay, err := bunker.pool.EnsureRelay(url) if err == nil { - relayConnectionWorked <- struct{}{} - + relayConnectionWorkedO() if err := relay.Publish(ctx, evt); err == nil { - select { - case bunkerConnectionWorked <- struct{}{}: - default: - } + bunkerConnectionWorkedO() } } }(url)