Skip to content

Commit eae828e

Browse files
committed
update to the fact that Pool doesn't use PoolOptions anymore, just modify the global pool directly.
1 parent 9ae5798 commit eae828e

9 files changed

Lines changed: 41 additions & 50 deletions

File tree

bunker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ var bunker = &cli.Command{
225225
}
226226
}
227227
relayURLs := make([]string, 0, len(allRelays))
228-
relays := connectToAllRelays(ctx, c, allRelays, nil, nostr.PoolOptions{})
228+
relays := connectToAllRelays(ctx, c, allRelays, nil)
229229
if len(relays) == 0 {
230230
log("failed to connect to any of the given relays.\n")
231231
os.Exit(3)

count.go

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,24 @@ var count = &cli.Command{
4343
if !c.Bool("force-pre-auth") {
4444
forcePreAuthSigner = nil
4545
}
46+
47+
sys.Pool.RelayOptions.AuthHandler = func(ctx context.Context, _ *nostr.Relay, aevt *nostr.Event) error {
48+
return authSigner(ctx, c, func(s string, args ...any) {
49+
if strings.HasPrefix(s, "authenticating as") {
50+
cleanUrl, _ := strings.CutPrefix(
51+
nip42.GetRelayURLFromAuthEvent(*aevt),
52+
"wss://",
53+
)
54+
s = "authenticating to " + color.CyanString(cleanUrl) + " as" + s[len("authenticating as"):]
55+
}
56+
log(s+"\n", args...)
57+
}, aevt)
58+
}
4659
relays := connectToAllRelays(
4760
ctx,
4861
c,
4962
relayUrls,
5063
forcePreAuthSigner,
51-
nostr.PoolOptions{
52-
RelayOptions: nostr.RelayOptions{
53-
AuthHandler: func(ctx context.Context, _ *nostr.Relay, authEvent *nostr.Event) error {
54-
return authSigner(ctx, c, func(s string, args ...any) {
55-
if strings.HasPrefix(s, "authenticating as") {
56-
cleanUrl, _ := strings.CutPrefix(
57-
nip42.GetRelayURLFromAuthEvent(*authEvent),
58-
"wss://",
59-
)
60-
s = "authenticating to " + color.CyanString(cleanUrl) + " as" + s[len("authenticating as"):]
61-
}
62-
log(s+"\n", args...)
63-
}, authEvent)
64-
},
65-
},
66-
},
6764
)
6865
if len(relays) == 0 {
6966
log("failed to connect to any of the given relays.\n")

dekey.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ var dekey = &cli.Command{
8787
// get relays for the user
8888
log("fetching write relays for %s\n", color.CyanString(nip19.EncodeNpub(userPub)))
8989
relays := sys.FetchWriteRelays(ctx, userPub)
90-
relayList := connectToAllRelays(ctx, c, relays, nil, nostr.PoolOptions{})
90+
relayList := connectToAllRelays(ctx, c, relays, nil)
9191
if len(relayList) == 0 {
9292
return fmt.Errorf("no relays to use")
9393
}

event.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,10 @@ example:
385385
}
386386

387387
if len(relayUrls) > 0 {
388-
relays = connectToAllRelays(ctx, c, relayUrls, nil,
389-
nostr.PoolOptions{
390-
AuthRequiredHandler: func(ctx context.Context, authEvent *nostr.Event) error {
391-
return authSigner(ctx, c, func(s string, args ...any) {}, authEvent)
392-
},
393-
},
394-
)
388+
sys.Pool.AuthRequiredHandler = func(ctx context.Context, authEvent *nostr.Event) error {
389+
return authSigner(ctx, c, func(s string, args ...any) {}, authEvent)
390+
}
391+
relays = connectToAllRelays(ctx, c, relayUrls, nil)
395392
if len(relays) == 0 {
396393
log("failed to connect to any of the given relays.\n")
397394
os.Exit(3)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/fiatjaf/nak
33
go 1.25
44

55
require (
6-
fiatjaf.com/nostr v0.0.0-20260416191442-f50b7b0f8dcb
6+
fiatjaf.com/nostr v0.0.0-20260419231400-94ea4328184f
77
github.com/AlecAivazis/survey/v2 v2.3.7
88
github.com/bep/debounce v1.2.1
99
github.com/btcsuite/btcd/btcec/v2 v2.3.6

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
fiatjaf.com/lib v0.3.6 h1:GRZNSxHI2EWdjSKVuzaT+c0aifLDtS16SzkeJaHyJfY=
22
fiatjaf.com/lib v0.3.6/go.mod h1:UlHaZvPHj25PtKLh9GjZkUHRmQ2xZ8Jkoa4VRaLeeQ8=
3-
fiatjaf.com/nostr v0.0.0-20260416191442-f50b7b0f8dcb h1:zOni3zgiu+hnzZFjt8SAMzmntlAxm+c8T9kEr0qwGRw=
4-
fiatjaf.com/nostr v0.0.0-20260416191442-f50b7b0f8dcb/go.mod h1:1cmygNC87Pw06/WjkZqDV+Xo6rV10kpTjzuayosIX4Y=
3+
fiatjaf.com/nostr v0.0.0-20260419231400-94ea4328184f h1:Y0KRSQnEDBxv5rxBJLSzGPOn5kwBCPAe2lri3+LEsKw=
4+
fiatjaf.com/nostr v0.0.0-20260419231400-94ea4328184f/go.mod h1:1cmygNC87Pw06/WjkZqDV+Xo6rV10kpTjzuayosIX4Y=
55
github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ=
66
github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo=
77
github.com/FastFilter/xorfilter v0.2.1 h1:lbdeLG9BdpquK64ZsleBS8B4xO/QW1IM0gMzF7KaBKc=

helpers.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ func connectToAllRelays(
186186
c *cli.Command,
187187
relayUrls []string,
188188
preAuthSigner func(ctx context.Context, c *cli.Command, log func(s string, args ...any), authEvent *nostr.Event) (err error), // if this exists we will force preauth
189-
opts nostr.PoolOptions,
190189
) []*nostr.Relay {
191190
// first pass to check if these are valid relay URLs
192191
for i, url := range relayUrls {

publish.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,11 @@ example:
152152
relayUrls = nostr.AppendUnique(relayUrls, targetRelays...)
153153
relayUrls = nostr.AppendUnique(relayUrls, replyRelays...)
154154
relayUrls = nostr.AppendUnique(relayUrls, c.Args().Slice()...)
155-
relays := connectToAllRelays(ctx, c, relayUrls, nil,
156-
nostr.PoolOptions{
157-
AuthRequiredHandler: func(ctx context.Context, authEvent *nostr.Event) error {
158-
return authSigner(ctx, c, func(s string, args ...any) {}, authEvent)
159-
},
160-
},
161-
)
155+
156+
sys.Pool.AuthRequiredHandler = func(ctx context.Context, authEvent *nostr.Event) error {
157+
return authSigner(ctx, c, func(s string, args ...any) {}, authEvent)
158+
}
159+
relays := connectToAllRelays(ctx, c, relayUrls, nil)
162160

163161
if len(relays) == 0 {
164162
if len(relayUrls) == 0 {

req.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -144,25 +144,25 @@ example:
144144
if !c.Bool("force-pre-auth") {
145145
forcePreAuthSigner = nil
146146
}
147+
148+
sys.Pool.AuthRequiredHandler = func(ctx context.Context, authEvent *nostr.Event) error {
149+
return authSigner(ctx, c, func(s string, args ...any) {
150+
if strings.HasPrefix(s, "authenticating as") {
151+
cleanUrl, _ := strings.CutPrefix(
152+
nip42.GetRelayURLFromAuthEvent(*authEvent),
153+
"wss://",
154+
)
155+
s = "authenticating to " + color.CyanString(cleanUrl) + " as" + s[len("authenticating as"):]
156+
}
157+
log(s+"\n", args...)
158+
}, authEvent)
159+
}
147160
relays := connectToAllRelays(
148161
ctx,
149162
c,
150163
relayUrls,
151164
forcePreAuthSigner,
152-
nostr.PoolOptions{
153-
AuthRequiredHandler: func(ctx context.Context, authEvent *nostr.Event) error {
154-
return authSigner(ctx, c, func(s string, args ...any) {
155-
if strings.HasPrefix(s, "authenticating as") {
156-
cleanUrl, _ := strings.CutPrefix(
157-
nip42.GetRelayURLFromAuthEvent(*authEvent),
158-
"wss://",
159-
)
160-
s = "authenticating to " + color.CyanString(cleanUrl) + " as" + s[len("authenticating as"):]
161-
}
162-
log(s+"\n", args...)
163-
}, authEvent)
164-
},
165-
})
165+
)
166166

167167
// stop here already if all connections failed
168168
if len(relays) == 0 {

0 commit comments

Comments
 (0)