-
Notifications
You must be signed in to change notification settings - Fork 53
how can i exit the program after the relays send an EOSE? #28
Comments
This needs to be implemented. |
When you first subscribe to a relay, you'll be flooded with messages, and then it will stop, and the channel will wait for new messages. You can create a loop with a timeout, and once the timeout is reached, you can break from it. Something like this would work: timeout := time.After(5 * time.Second)
tick := time.Tick(1 * time.Millisecond)
_, all := pool.Sub(nostr.Filters{})
unique := nostr.Unique(all)
for {
select {
case <-timeout:
fmt.Println("timeout")
break
case <-tick:
timeout = time.After(5 * time.Second)
event := <-unique
handleEvent(event)
}
} I wonder if it might be useful to have a reusable function that does the book-keeping for you. |
I implemented the helper in 7a5acc0 |
Actually, what we really need is to upgrade the go-nostr library. The EOSE stuff is already implemented there. The problem is though that we need to figure out our own way of doing relay pooling. |
yes, it is straight forward do do with go-nostr. here is one way I implemented this https://github.com/jeremyd/nostr-contacts/blob/main/cmd/backup.go#L130 |
I was attempting to add a get-contacts to synchronize my noscl contact list with the contact events I've sent from other clients.. I'd like the program to detect an EOSE from all relays and then save the config and exit, but I'm having a hard time figuring out how I might do that. Anyway, feel free to ignore this, but, if it's easy maybe we can document it or etc.. Thanks!
master...jeremyd:noscl:master
The text was updated successfully, but these errors were encountered: