adamritter / nostr-relaypool-ts

A Nostr RelayPool implementation in TypeScript using only nostr-tools library as a dependency
https://www.npmjs.com/package/nostr-relaypool
MIT License
63 stars 17 forks source link

Why do Authors use a callback syntax? #35

Open alexgleason opened 1 year ago

alexgleason commented 1 year ago

Is it safe to call it like this? I might be calling fetchUser hundreds of times - does the subscription ever get closed? I need something like getEventById for an author.

image

Thanks! This library has helped make pooling so much easier.

adamritter commented 1 year ago

Hi Alex,

you are right, it should actually use unsubscribeOnEose, which I added because of this, but not documented.

Could you please add it (and add to the documentation)?

Also right now, I'm focusing on https://rbr.bio/ metadata server that I want to integrate to RelayPool later. You can fetch the metadata by fetching https://rbr.bio/6e3f51664e19e082df5217fd4492bb96907405a0b27028671dd7f297b688608c/metadata.json with a timeout and only send request to relays if there's no result.

On Thu, Feb 23, 2023 at 12:13 PM Alex Gleason @.***> wrote:

Is it safe to call it like this? I might be calling fetchUser hundreds of times - does the subscription ever get closed? I need something like getEventById for an author.

[image: image] https://user-images.githubusercontent.com/3639540/220980174-f4352ae0-63ea-4739-8e24-e9bad1c77eaa.png

Thanks! This library has helped make pooling so much easier.

— Reply to this email directly, view it on GitHub https://github.com/adamritter/nostr-relaypool-ts/issues/35, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN5SWACU3U2MN53ZXVGAV73WY6LDVANCNFSM6AAAAAAVF4256Y . You are receiving this because you are subscribed to this thread.Message ID: @.***>

adamritter commented 1 year ago

The answer to the original question:

Why do Authors use a callback syntax?

Is because if there metadata is not the newest, and a newer is coming, you have to make sure that you are not overwriting an older metadata.

This problem is also why I'm working on the metadata server. Right now it has a 1 hour latency, but I'm working on fixing it.