-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: include parsers for outbox events #2
Comments
gm, I wanna extend my suggestion. Include a hint parameter to options object: opts?: {
signal?: AbortSignal,
hint?: Array<NostrEvent> | Array<WebSocket['url']>
} Then delivery this hint to This make sense? |
If you have a relay hint and want to use a specific relay, I think the way is to call const relay = pool.relay(hintUrl);
let [event] = await relay.query([filter], { signal });
// Optional: fall back to the pool
if (!event) {
event = await pool.query([filter], { signal });
} To use multiple relays from the pool, you could just do something like const relays = relayUrls.map((url) => pool.relay(url)); Then you have total control over the relays. If you're just looking for a single event by ID, I'd probably try: const [event] = Promise.race(
relays.map((relay) => relay.query([filter], { signal }),
); Using Promise.race, you can also try querying from a specific relay and the pool at the same time: const [event] = Promise.race(
pool.relay(hintUrl).query([filter], { signal }),
pool.query([filter], { signal }),
); ^ this one is probably the best one. |
To avoid distribute complexity into my application, I've decided centralized the cast (extract of relay url) of See how I customized my npool opts interface: export interface NPoolRequestOptions {
/**
* A AbortSignal allow you to emit an 'abort' event and stop request / publication when unsubscribe
*/
signal?: AbortSignal;
/**
* Relays to be included in the operation
*/
hint?: Array<WebSocket['url'] | NostrEvent | ProfilePointer | NProfile | undefined | null>;
/**
* Limit operation to these relays
*/
useOnly?: Array<WebSocket['url'] | NostrEvent | ProfilePointer | NProfile>;
/**
* Force ignore current configured ncache and nstore and request exclusively from relay
*/
ignoreCache?: boolean;
} I've tried to centralize nostr complexity into the services of my core lib. With that, dumb components can interact with nostr using only this customized pool and custom configs. With that custom configs it can be able to open events from a single relay or to load related content from an event, all without know If it's interacting with a relay, a pool of relays, if is ignoring cache. I'm not telling you too add that customized things to nostrify, I'm asking just to send |
Suggestion: include parser to cast outbox event (relay list, following list and r tag) into Record<string, { read: true, write: true }> or string[].
The text was updated successfully, but these errors were encountered: