mirror of
https://github.com/fiatjaf/nak.git
synced 2025-12-08 16:48:51 +00:00
req: print CLOSED messages.
This commit is contained in:
2
go.mod
2
go.mod
@@ -4,7 +4,7 @@ go 1.25
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
fiatjaf.com/lib v0.3.1
|
fiatjaf.com/lib v0.3.1
|
||||||
fiatjaf.com/nostr v0.0.0-20251201232830-91548fa0a157
|
fiatjaf.com/nostr v0.0.0-20251204122254-07061404918d
|
||||||
github.com/AlecAivazis/survey/v2 v2.3.7
|
github.com/AlecAivazis/survey/v2 v2.3.7
|
||||||
github.com/bep/debounce v1.2.1
|
github.com/bep/debounce v1.2.1
|
||||||
github.com/btcsuite/btcd/btcec/v2 v2.3.6
|
github.com/btcsuite/btcd/btcec/v2 v2.3.6
|
||||||
|
|||||||
2
go.sum
2
go.sum
@@ -2,6 +2,8 @@ fiatjaf.com/lib v0.3.1 h1:/oFQwNtFRfV+ukmOCxfBEAuayoLwXp4wu2/fz5iHpwA=
|
|||||||
fiatjaf.com/lib v0.3.1/go.mod h1:Ycqq3+mJ9jAWu7XjbQI1cVr+OFgnHn79dQR5oTII47g=
|
fiatjaf.com/lib v0.3.1/go.mod h1:Ycqq3+mJ9jAWu7XjbQI1cVr+OFgnHn79dQR5oTII47g=
|
||||||
fiatjaf.com/nostr v0.0.0-20251201232830-91548fa0a157 h1:14yLsO2HwpS2CLIKFvLMDp8tVEDahwdC8OeG6NGaL+M=
|
fiatjaf.com/nostr v0.0.0-20251201232830-91548fa0a157 h1:14yLsO2HwpS2CLIKFvLMDp8tVEDahwdC8OeG6NGaL+M=
|
||||||
fiatjaf.com/nostr v0.0.0-20251201232830-91548fa0a157/go.mod h1:ue7yw0zHfZj23Ml2kVSdBx0ENEaZiuvGxs/8VEN93FU=
|
fiatjaf.com/nostr v0.0.0-20251201232830-91548fa0a157/go.mod h1:ue7yw0zHfZj23Ml2kVSdBx0ENEaZiuvGxs/8VEN93FU=
|
||||||
|
fiatjaf.com/nostr v0.0.0-20251204122254-07061404918d h1:xROmiuT7LrZk+/iGGeTqRI4liqJZrc87AWjsyHtbqDg=
|
||||||
|
fiatjaf.com/nostr v0.0.0-20251204122254-07061404918d/go.mod h1:ue7yw0zHfZj23Ml2kVSdBx0ENEaZiuvGxs/8VEN93FU=
|
||||||
github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ=
|
github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ=
|
||||||
github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo=
|
github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo=
|
||||||
github.com/FastFilter/xorfilter v0.2.1 h1:lbdeLG9BdpquK64ZsleBS8B4xO/QW1IM0gMzF7KaBKc=
|
github.com/FastFilter/xorfilter v0.2.1 h1:lbdeLG9BdpquK64ZsleBS8B4xO/QW1IM0gMzF7KaBKc=
|
||||||
|
|||||||
23
req.go
23
req.go
@@ -227,6 +227,8 @@ example:
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var results chan nostr.RelayEvent
|
var results chan nostr.RelayEvent
|
||||||
|
var closeds chan nostr.RelayClosed
|
||||||
|
|
||||||
opts := nostr.SubscriptionOptions{
|
opts := nostr.SubscriptionOptions{
|
||||||
Label: "nak-req",
|
Label: "nak-req",
|
||||||
}
|
}
|
||||||
@@ -294,20 +296,29 @@ example:
|
|||||||
errg.Wait()
|
errg.Wait()
|
||||||
|
|
||||||
if c.Bool("stream") {
|
if c.Bool("stream") {
|
||||||
results = sys.Pool.BatchedSubscribeMany(ctx, defs, opts)
|
results, closeds = sys.Pool.BatchedSubscribeManyNotifyClosed(ctx, defs, opts)
|
||||||
} else {
|
} else {
|
||||||
results = sys.Pool.BatchedQueryMany(ctx, defs, opts)
|
results, closeds = sys.Pool.BatchedQueryManyNotifyClosed(ctx, defs, opts)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if c.Bool("stream") {
|
if c.Bool("stream") {
|
||||||
results = sys.Pool.SubscribeMany(ctx, relayUrls, filter, opts)
|
results, closeds = sys.Pool.SubscribeManyNotifyClosed(ctx, relayUrls, filter, opts)
|
||||||
} else {
|
} else {
|
||||||
results = sys.Pool.FetchMany(ctx, relayUrls, filter, opts)
|
results, closeds = sys.Pool.FetchManyNotifyClosed(ctx, relayUrls, filter, opts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ie := range results {
|
for {
|
||||||
stdout(ie.Event)
|
select {
|
||||||
|
case ie := <-results:
|
||||||
|
stdout(ie.Event)
|
||||||
|
case closed := <-closeds:
|
||||||
|
if closed.HandledAuth {
|
||||||
|
logverbose("%s CLOSED: %s\n", closed.Relay.URL, closed.Reason)
|
||||||
|
} else {
|
||||||
|
log("%s CLOSED: %s\n", closed.Relay.URL, closed.Reason)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user