close relay websockets cleanly.

This commit is contained in:
fiatjaf
2024-01-11 21:29:39 -03:00
parent 637b9440ef
commit a30f422d7d
3 changed files with 21 additions and 1 deletions

View File

@@ -24,6 +24,15 @@ var fetch = &cli.Command{
},
ArgsUsage: "[nip19code]",
Action: func(c *cli.Context) error {
pool := nostr.NewSimplePool(c.Context)
defer func() {
pool.Relays.Range(func(_ string, relay *nostr.Relay) bool {
relay.Close()
return true
})
}()
for code := range getStdinLinesOrFirstArgument(c) {
filter := nostr.Filter{}
@@ -67,7 +76,6 @@ var fetch = &cli.Command{
authorHint = v
}
pool := nostr.NewSimplePool(c.Context)
if authorHint != "" {
relayList := sdk.FetchRelaysForPubkey(c.Context, pool, authorHint,
"wss://purplepag.es", "wss://relay.damus.io", "wss://relay.noswhere.com",