namedLock() uses normalized uri and a simple test.

This commit is contained in:
fiatjaf 2024-05-29 08:39:24 -03:00
parent b00bf363c8
commit 0836352724
3 changed files with 16 additions and 3 deletions

2
go.mod
View File

@ -6,7 +6,6 @@ require (
github.com/bluekeyes/go-gitdiff v0.7.1
github.com/btcsuite/btcd/btcec/v2 v2.3.2
github.com/btcsuite/btcd/btcutil v1.1.3
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0
github.com/gobwas/httphead v0.1.0
github.com/gobwas/ws v1.2.0
github.com/mailru/easyjson v0.7.7
@ -27,6 +26,7 @@ require (
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/gobwas/pool v0.2.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect

14
helpers_test.go Normal file

File diff suppressed because one or more lines are too long

View File

@ -74,8 +74,7 @@ var _ PoolOption = (WithAuthHandler)(nil)
func (pool *SimplePool) EnsureRelay(url string) (*Relay, error) {
nm := NormalizeURL(url)
defer namedLock(url)()
defer namedLock(nm)()
relay, ok := pool.Relays.Load(nm)
if ok && relay.IsConnected() {