@@ -390,18 +390,31 @@ var bunker = &cli.Command{
390390 return
391391 }
392392
393- go func () {
394- for event := range sys .Pool .SubscribeMany (ctx , relays , nostr.Filter {
395- Kinds : []nostr.Kind {nostr .KindNostrConnect },
396- Tags : nostr.TagMap {"p" : []string {pubkey .Hex ()}},
397- Since : nostr .Now (),
398- LimitZero : true ,
399- }, nostr.SubscriptionOptions {Label : "nak-bunker" }) {
400- events <- event
393+ // compute new custom relays to avoid duplicate subscriptions
394+ newCustomRelays := make ([]string , 0 , len (relays ))
395+ for _ , r := range relays {
396+ if ! slices .Contains (allRelays , r ) {
397+ newCustomRelays = append (newCustomRelays , r )
398+ allRelays = append (allRelays , r )
401399 }
402- }()
400+ }
401+
402+ if len (newCustomRelays ) > 0 {
403+ log ("subscribing to %d new relays: %s\n " , len (newCustomRelays ), strings .Join (newCustomRelays , "," ))
404+ go func () {
405+ for event := range sys .Pool .SubscribeMany (ctx , relays , nostr.Filter {
406+ Kinds : []nostr.Kind {nostr .KindNostrConnect },
407+ Tags : nostr.TagMap {"p" : []string {pubkey .Hex ()}},
408+ Since : nostr .Now (),
409+ LimitZero : true ,
410+ }, nostr.SubscriptionOptions {Label : "nak-bunker" }) {
411+ events <- event
412+ }
413+ }()
414+
415+ time .Sleep (time .Millisecond * 25 )
416+ }
403417
404- time .Sleep (time .Millisecond * 25 )
405418 jresp , _ := json .MarshalIndent (resp , "" , " " )
406419 log ("~ responding with %s\n " , string (jresp ))
407420 for res := range sys .Pool .PublishMany (ctx , relays , eventResponse ) {
0 commit comments