nbd-wtf/go-nostr

Readme Error: No sub, no way to Unsub()

jraedisch opened this issue · 5 comments

The README.md example seems broken. There is no sub, just subId. Would submit PR but did not find a good way to unsub.

Referenced part of the README.md:

subId, events := pool.Sub(nostr.Filters{
	{
		Authors: []string{"0ded86bf80c76847320b16f22b7451c08169434837a51ad5fe3b178af6c35f5d"},
		Kinds:   []int{nostr.KindTextNote}, // or {1}
	},
})

go func() {
	for event := range nostr.Unique(events) {
		log.Print(event)
	}
}()

time.Sleep(5 * time.Second)
sub.Unsub()

You haven't figured it out yet have you? I just updated from 0.7.4 => 0.9.0 and trying to figure this out too. Subscriptions seem to be relay based rather than pool based now:

func (r *Relay) Subscribe(filters Filters) *Subscription {

@fiatjaf first branle, and now this?

The bug is acknowledged and will be fixed.

I don't understand what you're tagging me and talking about branle. If you are unhappy with the code please send a pull request fixing this or wait until I get to it.

Feel free to point me in some direction, maybe I'll be able to prepare a PR.

Sometimes I just like to tease you.

Fixed in #20 I hope

@jraedisch this is solved, can you confirm and close?