Currently, it is inefficient to fetch events related to the events that are fetched in a streaming manner (via allEventsIterator etc.) using nostr-fetch because we must wait until all events are fetched and then query related events and we can't run these fetches concurrently.
Introducing the concept of "subfetch" may resolve this issue.
API sketch:
NostrFetcher.subfetch<T>(stream: AsyncIterable<T>, deriveFilters: (v: T) => Filter[]): AsyncIterable<NostrEvent>
where:
stream is stream of things, usually NostrEvent but we have no reason to limit the type of items.
deriveFilters is a function that derives Filters from each item from the stream.
Considerations:
- How to batch and merge filters?
- If we request events by
ids, we don't have to wait responses from all relays.
Currently, it is inefficient to fetch events related to the events that are fetched in a streaming manner (via
allEventsIteratoretc.) using nostr-fetch because we must wait until all events are fetched and then query related events and we can't run these fetches concurrently.Introducing the concept of "subfetch" may resolve this issue.
API sketch:
NostrFetcher.subfetch<T>(stream: AsyncIterable<T>, deriveFilters: (v: T) => Filter[]): AsyncIterable<NostrEvent>where:
streamis stream of things, usuallyNostrEventbut we have no reason to limit the type of items.deriveFiltersis a function that derivesFilters from each item from thestream.Considerations:
ids, we don't have to wait responses from all relays.